iOS基础知识集合tom

浅谈IOS手势

2016-04-07  本文已影响449人  跑步的李磊

学习ios手势,先要了解响应链,ios中只要继承UIResponse对象的都能成为事件的响应者,当用户操作手机屏幕时,所操作的控件就是第一响应者,操作事件一步步向下传递(如果该控件不做处理)

事件响应链的传播路线:

First responder ->First responder的父视图(如果有)->父视图的视图控制器->UIWindow->UIApplication

response响应链

UIResponse的触碰方法:

/**** 触摸事件方法,对触摸事件进行处理 *****/

- (void)touchesBegan:(NSSet *)touches withEvent:(nullableUIEvent*)event;//触摸开始

- (void)touchesMoved:(NSSet *)touches withEvent:(nullableUIEvent*)event;//触摸移动

- (void)touchesEnded:(NSSet *)touches withEvent:(nullableUIEvent*)event;//触摸结束

- (void)touchesCancelled:(nullableNSSet *)touches withEvent:(nullableUIEvent*)event;//触摸取消

-(void)touchesEstimatedPropertiesUpdated(NSSet*_Nonnull)touchesNS_AVAILABLE_IOS(9_1);

//估计的触摸属性,主要用于3D touch                               


ios中主要的手势:

1.UITapGestureRecognizer //单击手势

单击

2.UIPinchGestureRecognizer //捏合手势

捏合

3.UIRotationGestureRecognizer //旋转手势

旋转

4.UISwipeGestureRecognizer //轻扫手势

轻扫

5.UIPanGestureRecognizer //拖动手势

拖动

6.UILongPressGestureRecognizer //长按手势

长按

参考文档:

ios事件处理  

iOS9 新特征之3D Touch实现


学习《疯狂的讲义-下》自己动手敲的,如果觉哪里理解的有无,请联系请求qq:876637125

相互学习,共同进步:)

上一篇下一篇

猜你喜欢

热点阅读