UIEvent继承于NSObject。一个UIEvent对象在iPhone OS中变现为事件。有三种类型的事件分别为
typedef NS_ENUM(NSInteger, UIEventType) {
UIEventTypeTouches, (触摸事件)
UIEventTypeMotion, (摇晃事件)
UIEventTypeRemoteControl, (遥控事件)
};
这里的遥控事件是指能够让一个响应者对象从外部配件或者耳机接受命令便可以管理音频和视频。触摸对象的事件类型包括一个或多个触摸(就是,手指触摸在屏幕上),触摸与某一事件联系在一起。一个触摸是被一个UITouch对象调用的。当一个事件触发了,系统将会把它传递给合适的响应对象并通过UIEvent对象发出一个消息调用UIResponder方法如touchesBegan:withEvent: 。响应对象可以分配触摸事件到合适的触摸类型并适当的控制他们。UIEvent中的方法可以让你获取全部的触摸事件(allTouches)或者给定的视图或者窗口(touchesForView: 或者 touchesForWindow:)。它可以分辨从响应对象传递过来的事件对象发生的时间(timestamp)。
获取事件中的触摸对象
timestamp property (事件发生的事件,为只读属性)
type
- touchesForGestureRecongnizer: - -
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,
};