iOS 设计中实现Cell自定义滑块操作
2016-03-23 22:01
465 查看
☐
☐ //实现Cell自定义滑动操作.........
-(NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
//添加一个删除按钮
UITableViewRowAction *Top1=[UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath)
{
//更新数据
[self.Array removeObjectAtIndex:indexPath.row];
//更新 tableview
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
//反馈执行 删除操作
NSLog(@"删除");
[tableView setEditing:NO animated:YES];
}];
//添加按钮背景色
Top1.backgroundColor=[UIColor redColor];
//添加一个置顶按钮
UITableViewRowAction *Top2=[UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"置顶" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath)
{
//刷新数据
[self.Array exchangeObjectAtIndex:indexPath.row withObjectAtIndex:0];
//把所选项置顶
NSIndexPath *FirstIndexPath=[NSIndexPath indexPathForRow:0 inSection:indexPath.section];
[tableView moveRowAtIndexPath:indexPath toIndexPath:FirstIndexPath];
//反馈执行置顶操作
NSLog(@"置顶");
[tableView setEditing:NO animated:YES];
}];
//设置按钮的背景色
Top2.backgroundColor=[UIColor grayColor];
//返回我们所设置的按钮 但是得以数组的形式返回
return @[Top1,Top2];
}
相关文章推荐
- iOS中代理属性用Weak修饰
- iOS 代理与通知,kvc和kvo的区别
- iOS instancetype与id的比较
- iOS import,include和class的区别
- iOS 本地通知
- ios assign、copy 、retain
- 【iOS】arc4random() 产生随机数
- iOS 2个坐标之间的距离
- iOS Animation动画 让图片不停的旋转360度
- 小案例-导入支付宝接口时经常出现这样的小错误"_OBJC_CLASS_$_UTDevice"
- iOS plist文件的增 删,改查
- iOS 倒计时验证码
- iOS tableView的分类
- iOS-常见加密总结
- iOS--轮播图实现
- IOS开发-OC学习-Foundation框架练习
- IOS开发-ObjC-NSDictionary
- iOS 8 Auto Layout界面自动布局系列3-使用代码添加布局约束
- iOS-NSDateFormatter 格式说明
- IOS开发-ObjC-NSArray