UITableViewCell:允许select性删除

我有一个表视图,并希望允许所有单元格的重新sorting,但有一些单元格,我不希望被允许删除。 当UiTableView进入删除模式时,我不想让红色的“ – ”button出现在左侧,也不希望滑动手势调出这些单元格的删除button,但希望它为其他人发生。 有任何想法吗?

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{ //if we cant delete the object represented at the index path if ([[tableViewObjectsArray objectAtIndex:indexPath.row] canBeDeleted] == NO){ return UITableViewCellEditingStyleNone; } //otherwise allow the deletion else{ return UITableViewCellEditingStyleDelete; } } 

当然,这留下一个空的空间,' – 'button应该是,但它不允许删除。 而且也不允许滑动删除。

实行:

 // Override to support conditional editing of the table view. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { // Return NO if you do not want the specified item to be editable. return YES; }