iOS开发小技巧--cell往左拖拽出现很多按钮的实现,仅仅适用于iOS8以后

Posted Chaos_G

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS开发小技巧--cell往左拖拽出现很多按钮的实现,仅仅适用于iOS8以后相关的知识,希望对你有一定的参考价值。

技术分享

 1 // 往左拖拽cell出现多个按钮的实现,仅仅适用于ios_8.0以后
 2 - (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
 3 {
 4     UITableViewRowAction *action = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
 5         NSLog(@"点击删除的时候调用");
 6     }];
 7     UITableViewRowAction *action2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"编辑" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
 8         NSLog(@"点击编辑的时候调用");
 9     }];
10     action2.backgroundColor = [UIColor grayColor];
11     return @[action,action2];
12 }

 

以上是关于iOS开发小技巧--cell往左拖拽出现很多按钮的实现,仅仅适用于iOS8以后的主要内容,如果未能解决你的问题,请参考以下文章