UIView 实现单击和双击的区别
2017-01-20 15:20
543 查看
1、viewload中添加UITapGestureRecognizer识别
// double tap
UITapGestureRecognizer * doubleTapRecognizer=
[[UITapGestureRecognizer
alloc]initWithTarget:self
action:@selector(doubleTap:)];
doubleTapRecognizer.numberOfTapsRequired=2;
doubleTapRecognizer.delaysTouchesBegan=YES;
[self.view
addGestureRecognizer:doubleTapRecognizer];
// single tap
UITapGestureRecognizer *tapRecognizer=
[[UITapGestureRecognizer
alloc]initWithTarget:self
action:@selector(tap:)];
// 关键在这一行,双击手势确定监测失败才会触发单击手势的相应操作
[tapRecognizer requireGestureRecognizerToFail:doubleTapRecognizer];
[self.view
addGestureRecognizer:tapRecognizer];
2、实现相关触发事件
-(void)doubleTap:(UIGestureRecognizer *) gr
{
NSLog(@"doubleTap");
}
-(void)tap:(UIGestureRecognizer *) gr
{
NSLog(@"tap");
}
// double tap
UITapGestureRecognizer * doubleTapRecognizer=
[[UITapGestureRecognizer
alloc]initWithTarget:self
action:@selector(doubleTap:)];
doubleTapRecognizer.numberOfTapsRequired=2;
doubleTapRecognizer.delaysTouchesBegan=YES;
[self.view
addGestureRecognizer:doubleTapRecognizer];
// single tap
UITapGestureRecognizer *tapRecognizer=
[[UITapGestureRecognizer
alloc]initWithTarget:self
action:@selector(tap:)];
// 关键在这一行,双击手势确定监测失败才会触发单击手势的相应操作
[tapRecognizer requireGestureRecognizerToFail:doubleTapRecognizer];
[self.view
addGestureRecognizer:tapRecognizer];
2、实现相关触发事件
-(void)doubleTap:(UIGestureRecognizer *) gr
{
NSLog(@"doubleTap");
}
-(void)tap:(UIGestureRecognizer *) gr
{
NSLog(@"tap");
}
相关文章推荐
- Gridview实现行单击和双击事件
- win32中如何区别“鼠标单击”和 “鼠标双击”
- [IOS]实现IOS单击或者双击事件
- JS实现鼠标单击与双击事件共存
- [IOS]实现IOS单击或者双击事件
- javascript 实现单击和双击并存
- 用VBS控制鼠标的实现代码(获取鼠标坐标、鼠标移动、鼠标单击、鼠标双击)
- 自定义Button实现屏蔽鼠标单击和双击
- 采用Jquery,在table上实现对行的单击、双击、返回选中行数据的功能,可作为GridView控制客户端的扩展
- android安卓如何实现单击提示“再按一次退出”,双击退出,实现双击监听
- GridView/DataGrid行单击和双击事件实现代码(转)
- wince下 在一个区域内实现既有单击事件又有双击事件
- GridView/DataGrid行单击和双击事件实现代码(转)
- 采用Jquery,在table上实现对行的单击、双击、返回选中行数据的功能,可作为GridView控制客户端的扩展
- jQuery单击双击实现链接的提取、插入与删除
- 【BCB 原创】深入 分析 C++Builder 6 的鼠标 单击 双击 事件 关键词: 单击 双击 实现机制
- javascript 实现单击和双击并存
- flash 中用单击事件区别处理双击和单击
- cocos2d-x2.1.5中实现手势识别(各种形状,单击,双击)
- cocos2dx实现精灵单击、双击、三击级拖拽分别处理