美文网首页ios-UI
ios11 tableview左滑到底删除禁用

ios11 tableview左滑到底删除禁用

作者: 我的名字就这么长 | 来源:发表于2018-02-27 11:32 被阅读1308次

- (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

相关文章

网友评论

    本文标题:ios11 tableview左滑到底删除禁用

    本文链接:https://www.haomeiwen.com/subject/fampxftx.html