思路1:
对cell增加长按手势。
失败,cell长按手势无法触发。
思路2:
1.对tableView增加 长按手势
2.通过手势获取point
3.通过point获取row
增加手势
longPress = [[UILongPressGestureRecognizer alloc]
initWithTarget:self
action:@selector(myHandleTableviewCellLongPressed:)];
longPress.minimumPressDuration = 1.0;
[self.tableView addGestureRecognizer:longPress];
……
CGPoint ponit=[gestureRecognizer locationInView:self.tableView];
//获取手势在传入的view的位置 (这里是单点)
//多点- (CGPoint)locationOfTouch:(NSUInteger)touchIndex inView:(UIView*)view;
NSIndexPath* path=[self.tableView indexPathForRowAtPoint:ponit];
//根据点击的point在table中找到相应的indexpath。
完整
-(void)tableviewCellLongPressed:(UILongPressGestureRecognizer *)gestureRecognizer{ if (gestureRecognizer.state == UIGestureRecognizerStateBegan) { NSLog(@"UIGestureRecognizerStateBegan"); CGPoint ponit=[gestureRecognizer locationInView:self.tableView]; NSLog(@" CGPoint ponit=%f %f",ponit.x,ponit.y); NSIndexPath* path=[self.tableView indexPathForRowAtPoint:ponit]; NSLog(@"row:%d",path.row); currRow=path.row; }else if(gestureRecognizer.state == UIGestureRecognizerStateEnded) { //未用 } else if(gestureRecognizer.state == UIGestureRecognizerStateChanged) { //未用 } }
相关推荐
ios TableViewCell收缩、伸缩、缩放功能
iOS TableViewCell 组件,选择单元格,然后显示一个下拉的详情信息。
长按即可移动cell的自定义TableView.zip,自定义的tableview,它可以开始移动单元格,只需长按一个手势。
tableViewCell按钮弹出视图
tableViewCell图片lazyload 图片延迟加载
用于tableViewCell 和 collectionViewCell 的移动 如发现问题请发邮件至ranheran@sohu.com,我会尽快修正
拖拽排序: 今日头条,网易新闻,订阅频道的拖拽排序功能简单实现。 支持标签长度不同。 [gitHub源码地址] (https://github.com/HelloYeah/DraggingSort)
在UITableViewCell里面加入自定义控件,本文以Lable为例,给读者提供一种动态控制Cell高度的思想,由这种思想出发,读者可以以此来动态控制cell的高度。
在github中有许多大牛封装好的第三发类库,其中有个自适应cell高度的类库 ...model类 commentsModel #import JSONModel.h #import getCommentData.h @interface commentsModel : JSONModel @property(nonatomic,copy)...
在XCode12中实现自定义TableViewCell微博事例,包含图片资源及plist数据
博客中的IOS TableView的Cell高度自适应,UILabel自动换行适应 的项目源码
tableviewcell的移动、删除、添加
代码简单易懂,这种代码还看不懂的话,那只能说基础不过关。核心代码就这一小段: DataModel *dmModel=self.nameArray[indexPath.row]; if (dmModel.checkboxOns==YES) { dmModel.checkboxOns=NO;...
iOS8新功能 TableViewCell滑动添加多个按钮,以后就不用自己计算位置了
IOS源码——自定义UITableViewCell。实现各种样式的表格输入界面.zip
iOS性能优化
tableviewcell 输入内容实时刷新高度 自适应高度 有不足的地方请指教 分享一些互相学习
好评率,进度的体验动画,颜色可自行修改
【iOS联动】新增功能:用户点击了左侧tableView中靠下的cell时,选中的cell会自动向上滚动。 github下载链接:https://github.com/leejayID/Linkage(欢迎Star,长期更新)。