UIResponder

UIResponder类定义了一个接口的对象的响应和处理事件。

UIApplication的超类,UIView及其子类(其中包括ui窗口)。这些类的实例是有时被称为响应者对象,或者简单,反应者。

事件

一般有两种类型的事件:触摸事件和运动事件。

接触的主要事件处理方法的touchesBegan:withEvent:,出来:withEvent:touchesEnded:withEvent:touchesCancelled:withEvent:。

这些方法的参数将接触与他们的事件——€”新的或改变了——特别是触摸€”从而允许响应者对象跟踪和处理触摸事件交付进度通过多点触控序列的阶段。

任何时候一个手指触摸屏幕,在屏幕上拖,或者从屏幕上电梯,UIEvent对象生成。

事件对象包含UITouch对象为所有的手指在屏幕上或解除。

iOS 3

iOS 3.0引入系统生成运动事件的功能,特别是震动的运动设备。 这些类型的事件的事件处理方法是motionBegan:withEvent:motionEnded:withEvent:,和motionCancelled:withEvent:。

此外,iOS 3.0 canPerformAction:withSender:方法允许救援人员来验证命令在用户界面undoManager属性返回最近的响应者链中的NSUndoManager对象。

iOS 4

UIResponder在iOS 4.0中,添加了remoteControlReceivedWithEvent:遥控处理事件的方法。

UIResponder内部提供了以下方法来处理事件

响应触摸事件

//1.触摸事件 

//一根或者多根手指开始触摸view,系统会自动调用view的下面方法
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;

//一根或者多根手指在view上移动,系统会自动调用view的下面方法(随着手指的移动,会持续调用该方法)
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;

//一根或者多根手指离开view,系统会自动调用view的下面方法
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;

//触摸结束前,某个系统事件(例如电话呼入)会打断触摸过程,系统会自动调用view的下面方法
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;

对运动事件

//2.加速计事件
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event;
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event;
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event;

对遥控事件

//3.远程控制事件
- (void)remoteControlReceivedWithEvent:(UIEvent *)event;

results matching ""

    No results matching ""