UIEvent【事件】属性和方法

6 篇文章 0 订阅

UIEvent【事件】属性和方法

官方文档:https://developer.apple.com/reference/uikit/uievent?language=objc#symbols

//触摸事件包括一个或者多个触摸(touches),每个触摸有一个UITouch对象表示。

//当触摸事件发生时,系统会通过触摸处理的逻辑找到合适的responder并把UIEvent对象传递过去。

//responder通过touchesBegan:withEvent:等方法去接收UIEvent对象。

 

@class UIWindow, UIView,UIGestureRecognizer, UITouch;

//三种事件类型

typedef NS_ENUM(NSInteger,UIEventType) {

    UIEventTypeTouches,         //触摸事件

    UIEventTypeMotion,           //运动事件

    UIEventTypeRemoteControl,   //远程控制事件

    UIEventTypePresses NS_ENUM_AVAILABLE_IOS(9_0), //物理按钮事件类型

};

 

//事件亚类型

typedef NS_ENUM(NSInteger,UIEventSubtype) {

   

    UIEventSubtypeNone                              = 0,//触摸事件的亚类型

    UIEventSubtypeMotionShake                       = 1,//摇晃

   

    UIEventSubtypeRemoteControlPlay                  = 100,//播放

    UIEventSubtypeRemoteControlPause                 = 101,//暂停

    UIEventSubtypeRemoteControlStop                 = 102,//停止

   UIEventSubtypeRemoteControlTogglePlayPause      = 103,//播放和暂停切换

    UIEventSubtypeRemoteControlNextTrack            = 104,//下一首

   UIEventSubtypeRemoteControlPreviousTrack        = 105,//上一首

   UIEventSubtypeRemoteControlBeginSeekingBackward = 106,//开始后退

   UIEventSubtypeRemoteControlEndSeekingBackward   = 107,//结束后退

   UIEventSubtypeRemoteControlBeginSeekingForward  = 108,//开始快进

   UIEventSubtypeRemoteControlEndSeekingForward    = 109,//结束快进

};

 

@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;

#ifUIKIT_DEFINE_AS_PROPERTIES

//所有的触摸

@property(nonatomic,readonly, nullable) NSSet <UITouch*> *allTouches;

#else

//所有的触摸

- (nullable NSSet <UITouch*> *)allTouches;

#endif

//获得UIWindow的触摸

- (nullable NSSet <UITouch*> *)touchesForWindow:(UIWindow *)window;

//获得UIView的触摸

- (nullable NSSet <UITouch*> *)touchesForView:(UIView *)view;

//获取事件中特定手势的触摸

- (nullable NSSet <UITouch*> *)touchesForGestureRecognizer:(UIGestureRecognizer *)gestureNS_AVAILABLE_IOS(3_2);

//会将丢失的触摸放到一个新的 UIEvent数组中,你可以用coalescedTouchesForTouch(_:)方法来访问

- (nullable NSArray <UITouch*> *)coalescedTouchesForTouch:(UITouch *)touch NS_AVAILABLE_IOS(9_0);

//辅助UITouch的触摸,预测发生了一系列主要的触摸事件。这些预测可能不完全匹配的触摸的真正的行为,因为它的移动,所以他们应该被解释为一个估计。

- (nullable NSArray <UITouch*> *)predictedTouchesForTouch:(UITouch *)touch NS_AVAILABLE_IOS(9_0);

 

@end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值