---恢复内容开始---

1.继承链:NSObject

2.UIGestureRecognizer的子类有以下:

3.想要使用手势一系列的行为需要遵守 UIGestureRecognizerDelegate协议

4.初始化手势识别器

    (1)- (instancetype)initWithTarget:(id)target
                        action:(SEL)action  :为一个对象初始化和分配空间,并设定手势的行为

5.添加和移除target和行为

    (1)- (void)addTarget:(id)target
           action:(SEL)action  :为手势识别器对象添加一个target,并设定指定的行为

    (2)- (void)removeTarget:(id)target
              action:(SEL)action  :从手势识别器中移除指定的target和指定的action

6.获取手势的touches和位置

    (1)- (CGPoint)locationInView:(UIView *)view  :返回指定视图被触摸的位置

    (2)- (CGPoint)locationOfTouch:(NSUInteger)touchIndex
                    inView:(UIView *)view  :触摸点相对于指定视图的位置

    (3)- (NSUInteger)numberOfTouches  :触摸点的数量

7.获取手势的状态和视图

    (1)@property(nonatomic, readonly) UIGestureRecognizerStatestate  :获取手势的状态

    (2)@property(nonatomic, readonly) UIView*view  :获取接受手势的视图

    (3)@property(nonatomic, getter=isEnabled) BOOL enabled  :手势是否可用

8.取消和延迟触摸

    (1)@property(nonatomic) BOOL cancelsTouchesInView  :取消视图的触摸

    (2)@property(nonatomic) BOOL delaysTouchesBegan  :延迟触摸的开始

    (3)@property(nonatomic) BOOL delaysTouchesEnded  :延迟触摸的结束

9.指定两个手势识别器的依赖

    (1)- (void)requireGestureRecognizerToFail:(UIGestureRecognizer *)otherGestureRecognizer  :只有当别的识别器触发失败的时候才使用该识别

10.设定委托

    (1)@property(nonatomic, weak) id< UIGestureRecognizerDelegate> delegate  :设定指定的委托

11.子类的方法

    (1)- (void)touchesBegan:(NSSet<UITouch *> *)touches
           withEvent:(UIEvent *)event  :触摸屏幕时开始执行这个方法

    (2)- (void)touchesMoved:(NSSet<UITouch *> *)touches
           withEvent:(UIEvent *)event  :触摸移动过程中执行这个方法

    (3)- (void)touchesEnded:(NSSet<UITouch *> *)touches
           withEvent:(UIEvent *)event  :触摸结束的时候执行这个方法

    (4)- (void)touchesCancelled:(NSSet<UITouch *> *)touches
               withEvent:(UIEvent *)event  :当触摸因为意外情况而取消就会执行这个方法

    (5)- (void)reset  :重置手势

    (6)- (void)ignoreTouch:(UITouch *)touch
           forEvent:(UIEvent *)event  :忽略某个事件的手势

    (7)- (BOOL)canBePreventedByGestureRecognizer:(UIGestureRecognizer *)preventingGestureRecognizer  :重载这个方法能够执行UIGestureRecognizerDelegate协议里面的方法gestureRecognizerShouldBegin: and gestureRecognizer:shouldReceiveTouch:.

    (8)- (BOOL)canPreventGestureRecognizer:(UIGestureRecognizer *)preventedGestureRecognizer  :Overridden to indicate that the receiver can prevent the specified gesture recognizer from recognizing its gesture.

    (9)- (BOOL)shouldRequireFailureOfGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer  :重载这个方法来设定接收者不响应指定的手势

    (10)- (BOOL)shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer  :重载这个方法来指定接收者应该被要求失败通过指定的手势识别器,Overridden to indicate that the receiver should be required to fail by the specified gesture recognizer.

    (11)- (void)ignorePress:(UIPress *)button
           forEvent:(UIPressesEvent *)event  :告诉手势识别器忽视按的事件

    (12)- (void)pressesBegan:(NSSet<UIPress *> *)presses
           withEvent:(UIPressesEvent *)event  :当按钮被按的时候发送事件到接收者

    (13)- (void)pressesChanged:(NSSet<UIPress *> *)presses
             withEvent:(UIPressesEvent *)event  :当按钮的压力变化的时候发送事件到接收者

    (14)- (void)pressesEnded:(NSSet<UIPress *> *)presses
           withEvent:(UIPressesEvent *)event  :当按钮结束按的动作的时候发送事件给接收者

    (15)- (void)pressesCancelled:(NSSet<UIPress *> *)presses
               withEvent:(UIPressesEvent *)event  :当按钮的按动作被取消的时候发送事件到接收者

12.配置不同的手势

    (1)@property(nonatomic, copy) NSArray<NSNumber *> *allowedPressTypes  :一组不同按的类型来区分按钮被按

    (2)@property(nonatomic, copy) NSArray<NSNumber *> *allowedTouchTypes  :一组不同的触摸类型,用来区分不同的touches

13.数据类型

    (1)UIGestureRecognizerState类型

UIGestureRecognizerStatePossible,

UIGestureRecognizerStateBegan,

UIGestureRecognizerStateChanged,

UIGestureRecognizerStateEnded,

UIGestureRecognizerStateCancelled,

UIGestureRecognizerStateFailed,

UIGestureRecognizerStateRecognized = UIGestureRecognizerStateEnded

---恢复内容结束---

UIKit框架之UIGestureRecognizer的更多相关文章

  1. UIKit框架使用总结--看看你掌握了多少

    一.经常使用的,基本就是每次项目迭代都需要使用的 UIView.UILabel.UIImage.UIColor.UIFont.UIImageView.UITextField.UIButton. UIS ...

  2. Swift - 重写UIKit框架类的init初始化方法(以UITabBarController为例)

    原来写了篇文章讲UITabBarController的用法,当时是从UIViewController跳转到UITabBarController页面,代码如下: 1 self.presentViewCo ...

  3. UIKit框架

    在今后的应用程序构建中,会陆续使用各式各样的控件,因此UIKit框架的引入是必不可少的! 一.简介 UIKitk框架提供一系列的Class(类)来建立和管理iPhone OS应用程序的用户界面接口.应 ...

  4. iOS学习32之UIKit框架-可视化编程-XIB

    1. Interface Builder 可视化编程 1> 概述 GUI : 图形用户界面(Graphical User Interface, 简称GUI, 又称图形化界面) 是指采用图形方式显 ...

  5. 基础框架Fundation和UIkit框架的定义和使用

    Foundation 框架为所有应用程序提供基本的系统服务 您的应用程序以及 UIKit 和其他框架,都建立在 Foundation 框架的基础结构之上.Foundation 框架提供许多基本的对象类 ...

  6. iOS开发概述UIkit动力学,讲述UIKit的Dynamic特性,UIkit动力学是UIkit框架中模拟真实世界的一些特性。

    转发:http://my.oschina.net/u/1378445/blog/335014 iOS UIKit动力学 Dynamics UIAttachmentBehavior 实现iMessage ...

  7. iOS开发UIKit框架-可视化编程-XIB

    1. Interface Builder 可视化编程 1> 概述 GUI : 图形用户界面(Graphical User Interface, 简称GUI, 又称图形化界面) 是指采用图形方式显 ...

  8. 79、iOS 的Cocoa框架、Foundation框架以及UIKit框架

    Cocoa框架是iOS应用程序的基础 1. Cocoa是什么? Cocoa是 OS X和ios 操作系统的程序的运行环境. 是什么因素使一个程序成为Cocoa程序呢?不是编程语言,因为在Cocoa开发 ...

  9. UIKit 框架之UIView二

    下面这些都是UIView一些基本的东西,具体的可以参考UIKit 框架之UIView一博客 一.自定义一个View // // MyView.m // UIView // // Created by ...

随机推荐

  1. Lua 与 Redis

    Lua 与 Redis 标签: Java与NoSQL 从 2.6版本 起, Redis 开始支持 Lua 脚本 让开发者自己扩展 Redis - 案例-实现访问频率限制: 实现访问者 $ip 在一定的 ...

  2. (49) odoo context操作

    * context  这是一个上下文,运用很灵活 * 得到整个context  V7  context=dict(context or {})  这个版本是明传  V8   self.context_ ...

  3. Web开发中管理ipad屏幕的方向变化

    Web开发中,我们会遇到在手机垂直或水平视角时展示不同状态的情况.下面我来总结一下检测移动设备方向变化的一些方法. 1 使用javascript 直接看代码: <script type=&quo ...

  4. python 执行execute遇到的问题

    1.如下方式去查询无法查询出结果,但直接在数据库查询中去查询是能查询到结果的,郁闷中,花了很久的时间才知道原来是双引号导致的 把:name="%s" 中的%s前后的双引号去掉就对了 ...

  5. Dynamo分布式系统——「RWN」协议解决多备份数据如何读写来保证数据一致性,而「向量时钟」来保证当读取到多个备份数据的时候,如何判断哪些数据是最新的这种情况

    转自:http://blog.jqian.net/post/dynamo.html Dynamo是Amazon开发的一款高可用的分布式KV系统,已经在Amazon商店的后端存储有很成熟的应用.它的特点 ...

  6. lock

    #ifndef lock_h #define lock_h #include <stdint.h> #include <string.h> #include "myd ...

  7. Angular js 之一些简单的js操作

    1.<div ng-if()> </div> 括号里面是布尔值  如果是false那么你ng-if的那个dom就会不显示.(感觉这是angular js中最给力的一点) 一般会 ...

  8. Python future模块

    今天看到了Pyhon中的模块__future__,查了一下资料,感觉这个module很有用. 从python2.1开始以后, 当一个新的语言特性首次出现在发行版中时候, 如果该新特性与以前旧版本pyt ...

  9. 1171. Lost in Space

    http://acm.timus.ru/problem.aspx?space=1&num=1171 一天的时间,WA了N遍,居然是因为数组开小了呀,我勒个去!鄙视自己...... 我是从第 1 ...

  10. 使用wex5得到的一些教训

    博主一直都是做web开发,前段时间有个小想法,想给自己做个android小应用(很小,功能特别简单). 了解到可以用js直接做,貌似很简单,选用了wex5(基于codova插件)来直接开发. 最终发现 ...