码迷,mamicode.com
首页 > 其他好文 > 详细

GestureRecognizer

时间:2014-11-23 00:30:00      阅读:273      评论:0      收藏:0      [点我收藏+]

标签:io   ar   os   使用   sp   on   cti   bs   ad   

UIGestureRecognizer基类是一个抽象类,我们主要是使用它的子类(名字包含链接,可以点击跳到ios Developer library,看官方文档):

UITapGestureRecognizer

UIPinchGestureRecognizer

UIRotationGestureRecognizer

UISwipeGestureRecognizer

UIPanGestureRecognizer

UILongPressGestureRecognizer

从名字上我们就能知道, Tap(点击)、Pinch(捏合)、Rotation(旋转)、Swipe(滑动,快速移动,是用于监测滑动的方向的)、Pan (拖移,慢速移动,是用于监测偏移的量的)以及 LongPress(长按)。

 

 

 

- (void)viewDidLoad

{

    [super viewDidLoad];

    UITapGestureRecognizer *gesture=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick:)];

    [self.view addGestureRecognizer:gesture];

    gesture.numberOfTapsRequired=1;

    gesture.numberOfTouchesRequired=1;

    

}

-(void)tapClick:(UITapGestureRecognizer *)gesture{

 

 

 

}

 

 

 

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event  //手指触摸屏幕时报告UITouchPhaseBegan事件

{

 

}

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event   //在手指在屏幕上移动时报告UITouchPhaseMoved事件

{

 

}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event   //在手指离开屏幕时报告UITouchPhaseEnded事件

{

 

}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event    //在因接听电话或其他因素导致取消触摸时报告

{

 

 

}

GestureRecognizer

标签:io   ar   os   使用   sp   on   cti   bs   ad   

原文地址:http://www.cnblogs.com/zhibin/p/4115989.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!