iOS開發UIEvent事件簡介

來源:互聯網
上載者:User

標籤:關聯   track   view   匹配   available   only   efi   系統   簡介   

1、UIEvent簡介

  UIEvent是代表iOS系統中的一個事件,一個事件包含一個或多個的UITouch;

  UIEvent分為四類: UIEventType

typedef NS_ENUM(NSInteger, UIEventType) {    UIEventTypeTouches,//觸摸事件類型 iOS3.0之後可以用    UIEventTypeMotion,//搖晃事件類型 iOS3.0之後可以用    UIEventTypeRemoteControl,//遙控事件類型 iOS4.0之後可以用    UIEventTypePresses NS_ENUM_AVAILABLE_IOS(9_0),//物理按鈕事件類型 iOS9.0之後可以用};

  子事件類型:UIEventSubtype

typedef NS_ENUM(NSInteger, UIEventSubtype) {    //事件沒有子類型 iOS3.0之後可以用    UIEventSubtypeNone                              = 0,        //事件子類型晃動的裝置 iOS3.0之後可以用    UIEventSubtypeMotionShake                       = 1,        //遙控的事件子類型 iOS4.0之後可以用    UIEventSubtypeRemoteControlPlay                 = 100,//播放    UIEventSubtypeRemoteControlPause                = 101,//暫停    UIEventSubtypeRemoteControlStop                 = 102,//停止    UIEventSubtypeRemoteControlTogglePlayPause      = 103,//播放和暫停之間切換【操作:播放或暫停狀態下,按耳機線控中間按鈕一下】    UIEventSubtypeRemoteControlNextTrack            = 104,//下一曲【操作:按耳機線控中間按鈕兩下】    UIEventSubtypeRemoteControlPreviousTrack        = 105,//上一曲【操作:按耳機線控中間按鈕三下】    UIEventSubtypeRemoteControlBeginSeekingBackward = 106,//快退開始【操作:按耳機線控中間按鈕三下不要鬆開】    UIEventSubtypeRemoteControlEndSeekingBackward   = 107,//快退結束【操作:按耳機線控中間按鈕三下到了快退的位置鬆開】    UIEventSubtypeRemoteControlBeginSeekingForward  = 108,//快進開始【操作:按耳機線控中間按鈕兩下不要鬆開】    UIEventSubtypeRemoteControlEndSeekingForward    = 109,//快進結束【操作:按耳機線控中間按鈕兩下到了快進的位置鬆開】};

 

2、相關API

NS_CLASS_AVAILABLE_IOS(2_0) @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 <UITouch *> *allTouches;#else- (nullable NSSet <UITouch *> *)allTouches;#endif- (nullable NSSet <UITouch *> *)touchesForWindow:(UIWindow *)window;//返回屬於一個給定視圖的觸摸對象,用於表示由接收器所表示的事件。- (nullable NSSet <UITouch *> *)touchesForView:(UIView *)view;//返回屬於一個給定視窗的接收器的事件響應的觸摸對象。- (nullable NSSet <UITouch *> *)touchesForGestureRecognizer:(UIGestureRecognizer *)gesture NS_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

 

iOS開發UIEvent事件簡介

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.