iOS8之后tableView新增加的代理方法

2016-06-02  本文已影响184人  AAALH

IOS8之后tableView新增的代理方法,可以在滑动的时候添加多个按钮

- (NSArray*)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{

UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {

[self.array removeObjectAtIndex:indexPath.row];

[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationBottom];

}];

//    deleteAction.backgroundColor = [UIColor greenColor]; //设置按钮颜色

UITableViewRowAction *ddAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"添加" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {

NSLog(@"点击了添加");

}];

return @[deleteAction,ddAction];

}

上一篇 下一篇

猜你喜欢

热点阅读