// 自动进入编辑模式,出现左滑效果
- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
// 回调方法里写点击事件
UITableViewRowAction *rowAction = [UITableViewRowAction rowActionWithStyle:(UITableViewRowActionStyleNormal) title:@"乐呵拉赫" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
NSLog(@"xixi");
}];
UITableViewRowAction *rowAction2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"乐呵你妹" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
NSLog(@"doubi");
}];
UITableViewRowAction *rowAction3 = [UITableViewRowAction rowActionWithStyle:(UITableViewRowActionStyleDefault) title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
NSLog(@"删了");
}];
UITableViewRowAction *rowAction4 = [UITableViewRowAction rowActionWithStyle:(UITableViewRowActionStyleDestructive) title:@"111" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
NSLog(@"222");
}];
rowAction.backgroundColor = [UIColor redColor];
rowAction2.backgroundColor = [UIColor greenColor];
NSArray *array = @[rowAction,rowAction3,rowAction2,rowAction4];
return array;
}
iOS8左滑出现三个按钮
最新推荐文章于 2020-03-05 21:55:15 发布
本文介绍了一个 iOS 应用中 UITableView 的编辑模式实现示例,通过自定义 UITableViewRowAction 实现了不同的行操作,包括不同样式的按钮及其点击事件。

2729

被折叠的 条评论
为什么被折叠?



