UISwipeGestureRecognizer 左右事件捕捉
转自:http://blog.163.com/china_uv/blog/static/117137267201252102612185/
UISwipeGestureRecognizer 左右事件相同为非注释代码, 左右事件不同为注释代码。
@implementation GestureRecognizerViewController
-(id)init
{
if (self == [super init]) {
UISwipeGestureRecognizer *recognizer;
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
[recognizer setDirection:UISwipeGestureRecognizerDirectionLeft|UISwipeGestureRecognizerDirectionRight];
[[self view] addGestureRecognizer:recognizer];
[recognizer release];
// recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
// [recognizer setDirection:UISwipeGestureRecognizerDirectionLeft];
// [[self view] addGestureRecognizer:recognizer];
// [recognizer release];
//
// recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
// [recognizer setDirection:UISwipeGestureRecognizerDirectionRight];
// [[self view] addGestureRecognizer:recognizer];
// [recognizer release];
}
return self;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor darkGrayColor];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-(void) dealloc
{
for (UISwipeGestureRecognizer *recognizer in [[self view] gestureRecognizers]) {
[[self view] removeGestureRecognizer:recognizer];
}
[super dealloc];
}
// ------------------------------------------------------------------------
- (void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer{
NSLog(@"direction ------------- %d", recognizer.direction);
if (recognizer.direction == (UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionRight)) {
NSLog(@"left & right");
}
// if (UISwipeGestureRecognizerDirectionLeft == recognizer.direction) {
// NSLog(@"left");
// }
//
// if (UISwipeGestureRecognizerDirectionRight == recognizer.direction) {
// NSLog(@"right");
// }
}
感叹下IOS的智慧,UISwipeGestureRecognizerDirection定义用的是位移。
typedef enum {
UISwipeGestureRecognizerDirectionRight = 1 << 0,
UISwipeGestureRecognizerDirectionLeft = 1 << 1,
UISwipeGestureRecognizerDirectionUp = 1 << 2,
UISwipeGestureRecognizerDirectionDown = 1 << 3
} UISwipeGestureRecognizerDirection;
UISwipeGestureRecognizer 左右事件捕捉的更多相关文章
- 事件冒泡(event bubbling)与事件捕捉(event capturing)
事件捕捉: 单击<div>元素就会以下列顺序触发click 事件. Document => Element html => Element body => Element ...
- Chromium网页输入事件捕捉和手势检測过程分析
连续的输入事件可能会产生一定的手势操作.比如滑动手势和捏合手势. 在Chromium中,网页的输入事件是在Browser进程中捕捉的.Browser进程捕获输入事件之后,会进行手势操作检測.检測出来的 ...
- QT 托盘 hover事件捕捉
1. QSystemTrayIcon hover事件 参考:https://stackoverflow.com/questions/21795919/how-to-catch-the-mousehov ...
- 谈事件冒泡(Bubble)和事件捕捉(capture)
事件的发生顺序 假设在一个元素中又嵌套了另一个元素并且两者都有一个onClick事件处理函数(event handler).如果用户单击元素2,则元素1和元素2的单击事件都会被触发.但是哪一个事件先被 ...
- 【Delphi】最小化事件捕捉
添加一个ApplicationEvents组件在窗体,然后处理其OnMinimize事件和OnRestore事件即可.
- js事件冒泡和事件捕捉
结论:他们是描述事件触发时序问题的术语.事件捕获指的是从document到触发事件的那个节点,即自上而下的去触发事件.相反的,事件冒泡是自下而上的去触发事件.绑定事件方法的第三个参数,就是控制事件触发 ...
- js··事件捕捉
给一个元素绑定事件,普通写法是 obj.onclick=function(){} 这就相当于给obj的onclick属性赋值是一个道理. obj.onclick=function(){} 这种写法有一 ...
- 模态框MODAL的一些事件捕捉
下表列出了模态框中要用到事件.这些事件可在函数中当钩子使用. 事件 描述 实例 show.bs.modal 在调用 show 方法后触发. $('#identifier').on('show.bs.m ...
- javascript 区域外事件捕捉setCapture
今天遇到了这个方法,便去度娘了解了下 函数功能:该函数在属于当前线程的指定窗口里设置鼠标捕获.一旦窗口捕获了鼠标,所有鼠标输入都针对该窗口,无论光标是否在窗口的边界内.同一时刻只能有一个窗口捕获鼠标. ...
随机推荐
- 八叉树(Octree)
八叉树(Octree)是一种用于描述三维空间的树状数据结构.想象一个立方体,我们最少可以切成多少个相同等分的小立方体?答案就是8个.再想象我们有一个房间,房间里某个角落藏着一枚金币,我们想很快的把金币 ...
- python3用http.server模块搭建简易版服务器
基本流程: 1.需要的支持 1)python3用http模块下的子模块,即:http.server模块 2)将希望共享的文件放在c盘下,如:C:\游戏行业面试专用 2.打开cmd,cd c:\\pyt ...
- in文件
in文件: 被调用的配置文件
- NTP国内时钟服务器
阿里云linux时钟服务器 ntp1.aliyun.comntp2.aliyun.comntp3.aliyun.comntp4.aliyun.comntp5.aliyun.comntp6.aliyun ...
- Zookeeper的Watcher机制
ZooKeeper 提供了分布式数据的发布/订阅功能, 在 ZooKeeper 中引入了 Watcher 机制来实现这种分布式的通知功能. ZooKeeper 允许客户端向服务端注册一个 Watche ...
- SpringBoot集成MyBatis的分页插件PageHelper
俗话说:好
- 设置span在div中垂直居中
转自:https://blog.csdn.net/weirenkuan/article/details/51177695 使用display:table-cell,span中内容无论多少,都可以垂直居 ...
- 转:一篇很全面的freemarker教程
最近在使用freemarker,于是在网上找了一些教程学习,如下: 以下内容全部是网上收集: FreeMarker的模板文件并不比HTML页面复杂多少,FreeMarker模板文件主要由如下4个部分组 ...
- Linux shell命令:用 !$ 防止误操作
shell 的通配符匹配非常强大,不过也非常危险,不少同学都碰到这样的问题,比如 rm a*,结果一个手抖,a 和星号之间多了个空格,结果目录下的文件都灰飞烟灭了…… bash 支持一个特殊的变量 ! ...
- strace命令解析
strace常用于跟踪和分析进程执行时中系统调用和耗时以及占用cpu的比例,常用的格式如下: 1.sudo /usr/bin/strace -Ttt -p pid 2>pid.log 跟进pid ...