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];
}
- (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];
}
相关文章推荐
- iOS 8 Xcode6 设置Launch Image 启动图片
- iOS单页面支持横屏的几种方法总结
- iOS移动View点击事件(二)
- iOS通过CIFilter对图像进行滤镜处理
- iOS开发手机号判断(截止到2016年5月的所有号段)
- 【iOS开发】Gitlab教程 (一)
- iOS状态栏&导航栏尺寸(宽度&高度)
- iOS 开发错误集合
- 一个小例子说明ios后台daemon程序获取iTunesstore信息
- iOS自定义的emoji表情键盘
- 如何编译ios上的可执行文件MACH-O
- iOS开发中使用正则表达式
- iOS性能优化
- 进程间通信 (OSX/iOS)
- iostat详细使用
- iOS GET和POST对比
- iOS 框架使用 -- 无消息提示 框架 DZNEmptyDataSet
- 游戏域名过期,ios审核涉及到ipv6的问题总结。
- iOS 常用的框架
- B站开源播放框架ijkplayer(iOS版)使用教程