美文网首页
iOS8之后tableView新增加的代理方法

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

作者: AAALH | 来源:发表于2016-06-02 16:23 被阅读184次

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];

}

相关文章

网友评论

      本文标题:iOS8之后tableView新增加的代理方法

      本文链接:https://www.haomeiwen.com/subject/mwdkdttx.html