ios - 单元格如何为 UITableView 删除

标签 ios uitableview cell

我在 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/

相关文章:

ios - 错误-swift-Tableview-自定义单元格

ios - 仅当在 Swift 中更改为 ON 状态时如何从开关调用选择器?

ios - 如果另一个项目不存在,Xcode 将项目居中对齐

alignment - FOP 表的单元格具有顶部和底部对齐的两个 block

ios - 在 UITableViewCell 中自动布局两个标签?

iphone - 如何设置自定义 UIView 的大小/位置以将其放置在自定义 UITableViewCell 中?

ios - 使用两个 UICollectionView 在 UITableView 中显示不同的数据

ios - Alamofire.requestObject 自定义案例未调用

iOS - 后台上传照片

ios - 在特定日期重复 UILocalNotification