How to disable "delete" when the table section is 0 on iPhone?
I have a UITableView with tw开发者_开发知识库o sections, and I added a edit button. If I press the edit button, I can delete the item on the UITableView, but I wanna to check the if the section is 0, the delete button will not display, how can I handle it for that purpose? Thank you.
Implement the tableView:canEditRowAtIndexPath:
method of the table view delegate in your view controller to check for the section. This and other edit methods control both edit and delete capabilities:
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0)
{
return NO;
}
return YES;
}
精彩评论