您的位置:首页 > 移动开发 > IOS开发

iOS8 之后tableview的delegate中新增加的代理方法,可以在滑动的时候添加多个按钮。

2016-06-03 12:46 471 查看
iOS8 之后tableview的delegate中新增加的代理方法,可以在滑动的时候添加多个按钮。

- (NSArray<UITableViewRowAction *> *)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];

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: