使TableviewCell排序手势占满cell条
来源:互联网 发布:淘宝海外买手 编辑:程序博客网 时间:2024/05/02 04:19
参考:http://blog.sina.com.cn/s/blog_702e40a80101iue2.html
另一种思路:http://www.jianshu.com/p/ce382f9bc794
突发奇想让tableviewcell排序的指示图标改动,能长按cell的任意位置可执行移动排序,主要思路就是让指示图标层形变。同样用形变的方法也可以让系统的移动指示图标位移。
先按照常规的做法 写好以下代码
//默认编辑模式下,每个cell左边有个红色的删除按钮,设置为None即可去掉- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{ return UITableViewCellEditingStyleNone;}//是否允许indexPath的cell移动- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath{ return YES;}- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath{ NSUInteger fromSection = [sourceIndexPath section]; //要移动的那个cell integer NSUInteger toSection = [<span style="font-family: Arial, Helvetica, sans-serif;">destinationIndexPath </span>section]; //要移动位置的那个cell integer //arrayValue 添加数据的那个可变数组 IGCellData *object = [datas objectAtIndex:fromSection]; // 获取数据 [datas removeObjectAtIndex:fromSection]; //在当前位置删除 [datas insertObject:object atIndex:toSection]; //插入的位置 //更新数据源[tableView reloadData];}
- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{ UAAMDirectoryCell *cellValue=(UAAMDirectoryCell *)cell; for(UIView* view in cellValue.subviews) { if([[[view class] description] isEqualToString:@"UITableViewCellReorderControl"]) { cellValue.movedReorderControl.frame=CGRectMake(0, 0, CGRectGetMaxX(view.frame)*2,CGRectGetMaxY(view.frame));//设置图标隐藏,形变放大 for (UIView *subview in view.subviews) { if ([subview isKindOfClass:[UIImageView class]]) { subview.hidden =YES; } } cellValue.movedReorderControl.userInteractionEnabled=YES; [cellValue.movedReorderControl addSubview:view]; CGAffineTransform transform = CGAffineTransformIdentity; cellValue.movedReorderControl .transform=CGAffineTransformScale(transform, SCREEN_SIZE.width/view.width*1.00, 1); } }}
movedReorderControl 是我在cell里面声明的一个View,在cell里判断编辑状态添加这个view,否则移除。
以上为核心的部分,像形变图层会覆盖cell表面,tableView进入编辑状态才可以进行移动 等细节方面还要多注意
0 0
- 使TableviewCell排序手势占满cell条
- 自定义cell,tableviewcell
- cell设置分割线占满cell的思路
- tableviewCell中Cell不能被点击
- 取得tableViewCell中的任意一个cell
- iOS 创建tableViewCell时 cell复用
- tableviewCell中Cell不能被点击
- tableViewcell上进行手势的添加
- 手势事件与TableViewCell点击事件冲突
- 环形手势控制条
- 自定义TableViewCell上的按钮-找到cell行数
- iOS 选择tableViewCell中的控件确定cell位置
- 通过代码自定义TableViewCell(针对cell高度不一致)
- TableViewCell中cell高度不一样时的优化
- tableViewCell 内部按钮点击事件 和 cell 高度变化操作
- 点击tableViewCell中的一个按钮,打印cell所在的行
- IOS TableViewCell分割线设置和隐藏多余cell
- iOS设置tableViewCell的cell、textLabel和detailTextLabel背景颜色
- mono+jexus安装
- QT中qstring和char *的互相转换
- 接口和实现类
- 基于netty游戏服后台搭建
- Ubuntu16.04搭建bugzilla缺陷管理系统
- 使TableviewCell排序手势占满cell条
- 浅谈jquery.fn.extend与jquery.extend区别
- Centos 6.5 Zabiix 配置Mysql服务
- shuqian
- Integer.valueof(string)字符串转Integer 异常
- ArcGIS制图表达Representation-制图表达原理
- 混合编程系列
- redis 个人理解和常用命令以及应用场景
- mysql主从同步延迟分析