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
今天遇到了这个方法,便去度娘了解了下 函数功能:该函数在属于当前线程的指定窗口里设置鼠标捕获.一旦窗口捕获了鼠标,所有鼠标输入都针对该窗口,无论光标是否在窗口的边界内.同一时刻只能有一个窗口捕获鼠标. ...
随机推荐
- 【Linux】ssh建立隧道tunnel连接到内网设备
root@192.168.1.105 建立隧道: ssh -l root -N -f -R 9103:127.0.0.1:2222 work@11.11.13.17 解析:把本地127.0.0.1:2 ...
- qt坐标系统与布局的简单入门
qt坐标系统 qt坐标系统比較简单 ); 上面的代码把button显示为父窗体的20,20处宽度为100,高度为100 接下去是布局 qt里面布局须要增加<QLayout.h>这个头 ...
- java 多重循环
//http://www.weixueyuan.net/view/6311.html //多重循环 import java.util.Scanner; public class Test16{ pub ...
- 三种常用的MySQL建表语句
MySQL建表语句是最基础的SQL语句之一,下面就为您介绍最常用的三种MySQL建表语句,如果您对MySQL建表语句方面感兴趣的话,不妨一看. 1.最简单的: CREATE TABLE t1( ...
- los中预览文件
#import <UIKit/UIKit.h> #import <QuickLook/QuickLook.h> @interface ViewController : UIVi ...
- 从html加载json文件想起
原文来自:https://www.cnblogs.com/dibaosong/p/4572274.html#top 文中给出了data.json文件内容 还给出了html文件内容 ok. 1.新建工程 ...
- JavaScript 数组(Array)对象
Array 对象 Array 对象用于在单个的变量中存储多个值. 创建 Array 对象的语法: new Array(); new Array(size); new Array(element0, e ...
- 【ASP.NET】@Model类型的使用详解
有时需要在ASP.NET MVC4的视图的@model中使用多个类型的实例,.NET Framework 4.0版本引入的System.Tuple类可以轻松满足这个需求. 假设Person和Produ ...
- js 对文件操作
下面是对此知识的系统介绍(转自互联网): Javascript是网页制作中离不开的脚本语言,依靠它,一个网页的内容才生动活泼.富有朝气.但也许你还没有发现并应用它的一些更高级的功能吧?比如,对文件和文 ...
- mysql-binlog_cache_size
二进制日志缓冲区吗,默认是32k.该参数是基于会话的,不要设置过大. 当事务的记录大于设定的binlog_cache_size时,mysql会把缓冲区中的日志信息写入一个临时文件中,所以该值也不能设置 ...