再iOS11上uitableview侧滑可以无限拉伸解决办法,iOS11多了一个方法,直接上代码:
- (nullable UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(nonnull NSIndexPath *)indexPath{
if (@available(iOS 11.0, *)) {
UIContextualAction *deleteAction = [UIContextualAction
contextualActionWithStyle:UIContextualActionStyleDestructive
title:@"删除"
handler:^(UIContextualAction * _Nonnull action,
__kindof UIView * _Nonnull sourceView,
void (^ _Nonnull completionHandler)(BOOL))
{
[tableView setEditing:NO animated:YES]; // 这句很重要,退出编辑模式,隐藏左滑菜单
/*
这中间为代码删除的具体逻辑实现
*/
completionHandler(true);
}];
UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[deleteAction]];
actions.performsFirstActionWithFullSwipe = NO;
return actions;
}else{
return nil;
}
}