这个是最终的实现效果。
代码实现,只需要实现这个方法就行
- (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath {
UIContextualAction *deleteAction1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleNormal title:nil handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
[tableView setEditing:NO animated:YES]; //退出编辑模式,隐藏左滑菜单
//点击删除按钮做的操作
}];
deleteAction1.backgroundColor = [[UIColor redColor] colorWithAlphaComponent:1.0];
deleteAction1.title = @"删除";
NSArray<UIContextualAction*> *contextualAction = @[deleteAction1];
UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:contextualAction];
actions.performsFirstActionWithFullSwipe = NO; // 禁止侧滑无线拉伸
return actions;
}
这样子就可以实现上面的侧滑效果了,但是我碰到的问题是在运行的时候选中的是运行虚拟机的技术是这个后面有带Rosetta的标识。
Rosetta是一种技术,用于在苹果的M1芯片上运行使用Intel x86架构的应用程序。M1芯片是苹果自家研发的基于ARM架构的芯片,与传统的Intel x86架构不兼容。为了保证应用程序的兼容性,Rosetta技术可以将使用Intel x86架构编译的应用程序在M1芯片上进行动态翻译和运行,以实现与Intel架构的应用程序的兼容性。
所以说这个并不是什么设备名,才导致我开始的时候实现的侧滑在滑动的时候根本没有效果出来,最后选中这个虚拟机运行就可以了。