UITableViewCell 添加长按手势
- UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
- lpgr.minimumPressDuration = 1.0; //seconds 设置响应时间
- lpgr.delegate = self;
- [mTableView addGestureRecognizer:lpgr]; //启用长按事件
- [lpgr release];
- -(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer //长按响应函数
- {
- CGPoint p = [gestureRecognizer locationInView:mTableView ];
- //if(gestureRecognizer.state == UIGestureRecognizerStateBegan)
- //{
- //NSLog(@"UIGestureRecognizerStateBegan");
- //}
- //else if(gestureRecognizer.state == UIGestureRecognizerStateEnded)
- //{
- //NSLog(@"UIGestureRecognizerStateEnded");
- //}
- //else if(gestureRecognizer.state == UIGestureRecognizerStateChanged)
- //{
- //NSLog(@"UIGestureRecognizerStateChanged");
- //}
- //else if(gestureRecognizer.state == UIGestureRecognizerStateCancelled)
- //{
- //NSLog(@"UIGestureRecognizerStateCancelled");
- //}
- //else if(gestureRecognizer.state ==UIGestureRecognizerStateFailed )
- //{
- //NSLog(@"UIGestureRecognizerStateFailed");
- //}
- NSIndexPath *indexPath = [mTableview indexPathForRowAtPoint:p];//获取响应的长按的indexpath
- if (indexPath == nil)
- NSLog(@"long press on table view but not on a row");
- else
- NSLog(@"long press on table view at row %d", indexPath.row);
- }
UITableViewCell 添加长按手势的更多相关文章
- ios 实现在tableViewCell上面添加长按手势 删除该条cell以及列表后台数据等
自己的代码 需要 把属性更改成自己要使用的 //创建长按手势 在cellForRowAtIndexPath代理方法中 UILongPressGestureRecognizer *longPres ...
- 给button添加长按手势并侦测到此button
1, 添加手势 self.longPressRecognizer = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@ ...
- iOS 利用长按手势移动 Table View Cells
本文译自:Cookbook: Moving Table View Cells with a Long Press Gesture 目录: 你需要什么? 如何做? 如何将其利用至UICollection ...
- IOS 关于tableview中cell的长按手势
说明:虽然是tableview中cell的长按手势 但是手势是添加在tableview上的 UILongPressGestureRecognizer *longpress = [[UILongPre ...
- Swift中实现点击、双击、捏、旋转、拖动、划动、长按手势的类和方法介绍
1.UITapGestureRecognizer 点击/双击手势 代码如下: var tapGesture = UITapGestureRecognizer(target: self, action: ...
- iOS长按手势调用两次解决方法
由于以前没有很细致的研究过长按手势,所以今天使用的时候发现长按手势会调用两次响应事件. 主要原因是长按手势会分别在UIGestureRecognizerStateBegan和UIGestureReco ...
- IOS 为UILabel添加长按复制功能
IOS 为UILabel添加长按复制功能 在iOS中下面三个控件,自身就有复制-粘贴的功能: 1.UITextView 2.UITextField 3.UIWebView UIKit framewor ...
- 自定义uitableviewcell通过加上滑动手势进行删除对应的行。PS:用代理来实现
#import <UIKit/UIKit.h> @class ZSDCustomCell; //协议 @protocol ZSDCustomCellDelegate <NSObjec ...
- Swift - 给表格的单元格UITableViewCell添加图片,详细文本标签
表格UITableView中,每一单元格都是一个UITableViewCell.其支持简单的自定义,比如在单元格的内部,添加图片和详细文本标签. 注意UITableViewCell的style: (1 ...
随机推荐
- Defining as a "long" or "int" type throws an error on startup
solr启动时候,报如下异常: [java] view plaincopy SEVERE: org.apache.solr.common.SolrException at org.a ...
- UVa10047 The Monocycle
UVa10047 The Monocycle 链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=19491 (以上摘自htt ...
- MHz 和 Mbps的区别
Hz是频率单位,例如10Hz就是表示每秒运算10次 Mbps是Million bit per secend (表示每秒传输的兆位数)=Mb/s MHz 和 Mbps 并不是同一个单位,关键是看bus的 ...
- ACM2054_A=B
/* 问题说明 给你两个号码A和B,如果A等于B,您应打印“YES”,或打印“NO”. 输入 每个测试案例包含A和B两个数字 产量 每一种情况下,如果A等于B,您应打印“YES”,或打印“NO”. 采 ...
- Ural 1046 Geometrical Dreams(解方程+计算几何)
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1046 参考博客:http://hi.baidu.com/cloudygoose/item ...
- redis ins 调试
Redis简介: Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API.从2010年3月15日起,Redis的开发工 ...
- Maven学习系列二(1-5)
Maven学习系列二(1-5) 本文转自 QuantSeven 博客,讲解精炼易懂,适合入门,链接及截图如下 http://www.cnblogs.com/quanyongan/category/47 ...
- 转 MySQL 用户权限详细汇总
http://blog.csdn.net/mchdba/article/details/45934981 1,MySQL权限体系 MySQL 的权限体系大致分为5个层级: 全局层级: 全局权限适用于一 ...
- [Reactive Programming] Async requests and responses in RxJS
We will learn how to perform network requests to a backend using RxJS Observables. A example of basi ...
- Hadoop WritableComparable接口
WritableComparable接口 Writable接口大家可能都知道,它是一个实现了序列化协议的序列化对象.在Hadoop中定义一个结构化对象都要实现Writable接口,使得该结构化对象可以 ...