码迷,mamicode.com
首页 > 移动开发 > 详细

IOS中的三大事件

时间:2015-08-07 13:11:43      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

  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, };

 

 

  

IOS中的三大事件

标签:

原文地址:http://www.cnblogs.com/pengpengzhang/p/4710343.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!