UITableView滑动删除
StackOverFlow回答:
// During startup (-viewDidLoad or in storyboard) do:
self.tableView.allowsMultipleSelectionDuringEditing = NO;
// Override to support conditional editing of the table view.
// This only needs to be implemented if you are going to be returning NO
// for some items. By default, all items are editable.
- (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
}
}
个人推荐第三方:SWTableViewCell
StackOverFlow
本文详细介绍了如何在UITableView中实现滑动删除功能,并推荐使用第三方库SWTableViewCell来简化开发过程。通过覆盖tableView的canEditRowAtIndexPath、commitEditingStyle等方法,可以实现在iOS应用中对表格项进行条件编辑和删除操作。
1157

被折叠的 条评论
为什么被折叠?



