关于IOS11上UItableview侧滑删除无线拉伸的问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_28551705/article/details/79631602

再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;

    }


}


猜你喜欢

转载自blog.csdn.net/qq_28551705/article/details/79631602