zoukankan      html  css  js  c++  java
  • IOS中的三大事件

      iOS 中,所有显示在界面上的对象都是从 UIResponder 直接或间接继承的,只有继承了它才可以处理事件。而在ios中的事件可以分为三大类:   

        1.触摸事件

        2.加速计事件(摇一摇)

        3.远程控制事件 

      只要手指触摸屏幕,滑动,从屏幕离开,系统都会产生UIEvent对象类型的事件---当然包括UITouch事件

           

    1 /**
    2  *  开始触摸(也就是手指触摸屏幕(view)那一刻)
    3  */
    4 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
    1 /**
    2  *  触摸进行中。。。。
    3  */
    4 -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
    /**
     *  触摸结束
     */
    -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
    1 /**
    2  *  触摸中断
    3  */
    4 -(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;

      iOS 3.0 + 开始支持motion事件,特别是摇动设备,例如:微信中的摇一摇功能。

    // 运动开始时执行
    - (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);

      iOS 4.0 + 开始支持远程事件

    - (void)remoteControlReceivedWithEvent:(UIEvent *)event NS_AVAILABLE_IOS(4_0);

    // 下面是UIEventType三种事件类型的枚举定义
    typedef NS_ENUM(NSInteger, UIEventType) { UIEventTypeTouches, UIEventTypeMotion, UIEventTypeRemoteControl, }; typedef NS_ENUM(NSInteger, UIEventSubtype) {
    // available in iPhone OS 3.0 UIEventSubtypeNone = 0, // for UIEventTypeMotion, available in iPhone OS 3.0 UIEventSubtypeMotionShake = 1, // for UIEventTypeRemoteControl, available in iOS 4.0 UIEventSubtypeRemoteControlPlay = 100, UIEventSubtypeRemoteControlPause = 101, UIEventSubtypeRemoteControlStop = 102, UIEventSubtypeRemoteControlTogglePlayPause = 103, UIEventSubtypeRemoteControlNextTrack = 104, UIEventSubtypeRemoteControlPreviousTrack = 105, UIEventSubtypeRemoteControlBeginSeekingBackward = 106, UIEventSubtypeRemoteControlEndSeekingBackward = 107, UIEventSubtypeRemoteControlBeginSeekingForward = 108, UIEventSubtypeRemoteControlEndSeekingForward = 109, };

      

  • 相关阅读:
    Tiny64140之初始化时钟
    Tiny6410之控制icache驱动
    Tiny6410之按键裸机驱动
    Linux -- man 、info、 whatis、 -h
    Linux -- which whereis
    Linux -- sudoers (简单:转)
    Linux -- sudo
    Linux -- sudoers文件
    Linux -- cp
    Linux -- mv
  • 原文地址:https://www.cnblogs.com/pengpengzhang/p/4710343.html
Copyright © 2011-2022 走看看