zoukankan      html  css  js  c++  java
  • 手势(UIGestureRecognizer)

    通过继承 UIGestureRecognizer 类,实现自定义手势(手势识别器类)。

    PS:自定义手势时,需要 #import <UIKit/UIGestureRecognizerSubclass.h>,一般需实现如下方法:

    1 - (void)reset;
    2 
    3 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
    4 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
    5 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
    6 - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
    7 //以上方法在分类 UIGestureRecognizer (UIGestureRecognizerProtected) 中声明,更多方法声明请自行查看

    手势状态枚举如下:

    1 typedef NS_ENUM(NSInteger, UIGestureRecognizerState) {
    2     UIGestureRecognizerStatePossible,   // 尚未识别是何种手势操作(但可能已经触发了触摸事件),默认状态
    3     UIGestureRecognizerStateBegan,      // 手势已经开始,此时已经被识别,但是这个过程中可能发生变化,手势操作尚未完成
    4     UIGestureRecognizerStateChanged,    // 手势状态发生转变
    5     UIGestureRecognizerStateEnded,      // 手势识别操作完成(此时已经松开手指)
    6     UIGestureRecognizerStateCancelled,  // 手势被取消,恢复到默认状态
    7     UIGestureRecognizerStateFailed,     // 手势识别失败,恢复到默认状态
    8     UIGestureRecognizerStateRecognized = UIGestureRecognizerStateEnded // 手势识别完成,同UIGestureRecognizerStateEnded
    9 };
  • 相关阅读:
    python网络编程,requests模块
    python操作excel
    python加密模块hashlib
    python操作redis
    python操作mysql
    python常用模块3(os和sys模块)
    python打开网站
    python常用模块2
    python模块简介
    mac下开发——环境心得(杂项,持续性更新)
  • 原文地址:https://www.cnblogs.com/jingdizhiwa/p/5795686.html
Copyright © 2011-2022 走看看