UITableViewCell prevents deletion
2 answers
Inject editStyleForRowAtIndexPath and return UITableViewCellEditingStyleNone for this row:
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == sss && indexPath.row == rrr)
return UITableViewCellEditingStyleNone;
else
return UITableViewCellEditingStyleDelete;
}
+7
a source to share
The accepted answer works, but this is not the correct way to do it. There are two methods available: editingStyleForRowAtIndexPath
andcanEditRowAtIndexPath
editStyleForRowAtIndexPath . Use if the table has several different editing styles.
canEditRowAtIndexPath . Use when some lines should be edited and some shouldn't.
So the correct way to implement a table delegate is:
- (BOOL)tableView:(UITableView *)tableView
canEditRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == sss && indexPath.row == rrr)
{
return NO;
}
return YES;
}
+2
a source to share