开发者

How to disable slide to delete for a UITableView

Does anybody know how to disable the 'slide-to-delete' in a uitableview?

I still want to be able to delete the r开发者_如何学Goows while the table is in editing mode.


Mine is:

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath 
{
   return self.editing ;
}


First, to confirm if a table cell can be deleted simply reply to canEditRowAtIndexPath.

-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
  // Return YES or NO
  return(YES);
  }
}

Then, to actually delete the table cell reply to commitEditingStyle.

-(void)tableView:(UITableView *)tv commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
  if (editingStyle == UITableViewCellEditingStyleDelete) {
  // Delete your data

  // Delete the table cell
  [self.tableView deleteRowAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
  }
}

Good luck Mats Stijlaart!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜