ios11 tableview左滑到底删除禁用
- (nullable UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos){
// delete action
UIContextualAction *deleteAction = [UIContextualAction
contextualActionWithStyle:UIContextualActionStyleDestructive
title:@"删除"
handler:^(UIContextualAction * _Nonnull action,
__kindof UIView * _Nonnull sourceView,
void (^ _Nonnull completionHandler)(BOOL))
{
[tableView setEditing:NO animated:YES]; // 这句很重要,退出编辑模式,隐藏左滑菜单
[self.arr removeObjectAtIndex:indexPath.row];
[_table deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationMiddle];
[_table reloadData];
completionHandler(true);
}];
UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[deleteAction]];
actions.performsFirstActionWithFullSwipe = NO;
return actions;
}
参考:http://www.cocoachina.com/bbs/read.php?tid-1731241.html