如何在 UITableViewCell
上滑动时显示删除按钮?该事件永远不会引发,删除按钮也永远不会出现。
最佳答案
在(-viewDidLoad 或storyboard)中启动时
做:
self.tableView.allowsMultipleSelectionDuringEditing = false
覆盖以支持表格 View 的条件编辑。仅当您要为某些项目返回 NO
时,才需要执行此操作。默认情况下,所有项目都是可编辑的。
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// Return YES if you want the specified item to be editable.
return YES;
}
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
//add code here for when you hit delete
}
}
https://stackoverflow.com/questions/3309484/