简体   繁体   English

当向左滑动表格视图单元格到手机的左边缘时,它将自动触发删除UITableViewRowAction,如何禁用此功能?

[英]when left swipe a tableview cell to the left edge of the phone, it will auto trigger the delete UITableViewRowAction , how to disable this?

when left swipe a tableview cell to the left edge of the phone, it will auto trigger the delete UITableViewRowAction , how to disable this? 当向左滑动表格视图单元格到手机的左边缘时,它将自动触发删除UITableViewRowAction,如何禁用此功能? 在此处输入图片说明

on ios11 ,the swipe action is defined in the delegate method : 在ios11上,滑动动作是在委托方法中定义的:

-(UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(11_0){
    UIContextualAction *deleteAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleNormal title:@"哈喽" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
        NSLog(@"hello");
        completionHandler(YES);
    }];
    UISwipeActionsConfiguration *config = [UISwipeActionsConfiguration configurationWithActions:@[deleteAction]];
    config.performsFirstActionWithFullSwipe = NO;//this line will disable auto trigger the action when perform full swipe
        return config;
}

if this delegate method is not impelemented,it will use the 如果此委托方法不受阻碍,它将使用

-(NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath 

the auto trigger action is determined by the UISwipeActionsConfiguration's performsFirstActionWithFullSwipe , so just set this value to false 自动触发操作由UISwipeActionsConfiguration的performFirstActionWithFullSwipe确定,因此只需将此值设置为false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM