zoukankan      html  css  js  c++  java
  • iOS中的触摸事件,手势识别,摇晃事件等

    在iOS中,事件可以划分为以下几类:

    1.触摸事件:通过触摸,手势进行触发(手指点击、缩放等)

    2.运动事件:通过加速器触发(例如手机晃动)

    3.远程控制事件:通过其他远程设备触发(例如耳机控制按钮)

    在iOS中并不是所有的类都能处理接收并事件,只有继承自UIResponder类的对象才能处理事件(如我们常用的UIView、 UIViewController、UIApplication都继承自UIResponder,它们都能接收并处理事件)。在UIResponder中 定义了上面三类事件相关的处理方法:

    触摸事件:

    //一根或多根手指开始触摸屏幕时执行;

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;

    //一根或多根手指在屏幕上移动时执行,注意此方法在移动过程中会重复调用;

    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;

    //一根或多根手指触摸结束离开屏幕时执行;

    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;

    //触摸意外取消时执行(例如正在触摸时打入电话);

    - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;

    运动事件:

    //运动开始时执行;

    - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event NS_AVAILABLE_IOS(3_0);

    //运动结束后执行;

    - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event NS_AVAILABLE_IOS(3_0);

    //运动被意外取消时执行

    - (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event NS_AVAILABLE_IOS(3_0);

  • 相关阅读:
    Mac从零配置Vim
    Mac效率:配置Alfred web search
    看看你的邻居在干什么
    成功破解邻居的Wifi密码
    MacBook安装Win10
    C陷阱:求数组长度
    Nexus 6P 解锁+TWRP+CM
    搭建树莓派手机远程开门系统
    Ubuntu下配置ShadowS + Chrome
    JS传参出现乱码(转载)
  • 原文地址:https://www.cnblogs.com/iOSDeng/p/5103246.html
Copyright © 2011-2022 走看看