gpt4 book ai didi

ios - 单元格如何为 UITableView 删除

转载 作者:行者123 更新时间:2023-11-28 20:01:57 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com