我在 TableView Cell
上有最多的 IBOutlet
它们覆盖单元格 swipe
向左操作。
Cell 只有少量空间触发 delete Action 。
帮帮我
如何在单元格上的 IBOutlet 中添加 SwipeGestureRecognizer
最佳答案
首先,添加这个:
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
然后
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
//remove the deleted object from your data source.
//If your data source is an NSMutableArray, do this
[self.dataArray removeObjectAtIndex:indexPath.row];
[tableView reloadData]; // tell table to refresh now
}
}
关于ios - 单元格如何为 UITableView 删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23627410/