UIEvent官方文档
1、触摸事件:第一个手指开始触摸屏幕到最后一个手指离开屏幕定义为一个触摸事件。
2、UIEvent实际包括了多个UITouch对象。有几个手指触碰,就会有几个UITouch对象。
@interface UIEvent : NSObject
@property(nonatomic,readonly) UIEventType type NS_AVAILABLE_IOS(3_0);
@property(nonatomic,readonly) UIEventSubtype subtype NS_AVAILABLE_IOS(3_0);
@property(nonatomic,readonly) NSTimeInterval timestamp;
#if UIKIT_DEFINE_AS_PROPERTIES
@property(nonatomic, readonly, nullable) NSSet *allTouches;
//省略部分代码
@end
typedef NS_ENUM(NSInteger, UIEventType) {
UIEventTypeTouches, // 触摸事件
UIEventTypeMotion, // 加速计事件
UIEventTypeRemoteControl, // 远程事件
UIEventTypePresses , // 物理按压事件
};
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,
};
UIEvent中包含若干UITouch,当某个UITouch对象的phase状态发生变化,系统会产生一条TouchMessage,继而传递和派发Touch message。
也就是说每次用户手指的移动和变化,UITouch都会形成状态改变,系统便会产生TouchMessage。一次触摸事件是由一组UITouch对象状态变化引起的一组Touch message的传递和转发。