1.0 iOS中的事件

jopen 8年前發布 | 8K 次閱讀 iOS開發 移動開發

在用戶使用app過程中,會產生各種各樣的事件,iOS中的事件可以分為3大類型:

UIKit可識別三種類型的輸入事件:

  • 觸摸事件
  • 加速計事件 / 運動事件
  • 遠程控制事件

UIResponder - 響應者對象
概念:
在iOS中不是任何對象都能處理事件,只有繼承了UIResponder的對象才能接收并處理事件。
成員:
UIApplication、UIViewController、UIView都繼承自UIResponder,因此它們都是響應者對象,都能夠接收并處理事件
UIResponder的內部方法:
1 //觸摸事件
2 - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;
3 - (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;
4 - (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;
5 - (void)touchesCancelled:(nullable NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;
6 - (void)touchesEstimatedPropertiesUpdated:(NSSet * _Nonnull)touches NS_AVAILABLE_IOS(9_1);
1 //加速計事件
2 - (void)motionBegan:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(3_0);
3 - (void)motionEnded:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(3_0);
4 - (void)motionCancelled:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(3_0);
//遠程控制事件
- (void)remoteControlReceivedWithEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(4_0);

如有疑問,請發送郵件至  shorfng@126.com 聯系我。

By:藍田(Loto)

</div>

</div> </div>

來自: http://www.cnblogs.com/shorfng/p/5133910.html

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!