UIResponder类

时间:2023-03-09 22:44:45
UIResponder类

UIResponder类

UIResponder类是所有视图类的父类,包括UIView, UIApplication, UIWindow.

UIResponder类定义了一些响应和处理事件的方法。事件分为触屏事件,移动事件和远程控制事件。

触屏事件打方法:
touchesBegan:withEvent: 触屏开始

touchesMoved:withEvent: 移动当中

touchesEnded:withEvent: 触屏结束

touchesCancelled:withEvent: 触屏取消

移动事件的方法:

motionBegan:withEvent  开始移动

motionEnded:withEvent  结束移动

motionCancelled:withEvent 取消移动

另外,该类还定义了一些事件传递链的方法:

nextResponder 下一个响应者

isFirstResponder  是否是第一个响应者

canBecomefirstResponder  能否成为第一个响应者

-      
becomeFirstResponder  成为第一个响应者

canResignFirstResponder  能取消第一个响应者

resignFirstResponder  取消第一个响应者