http://www.cnblogs.com/lingzhao/p/3536230.html?utm_source=tuicoolManaging the Responder Chain
UIResponder类不自动存储和设置下一个响应者,而是默认返回nil。子类必须override这个方法来设置下一个响应者。 UIView实现了这个方法,因为可以返回管理这个UIView的UIViewController或者它的父类; UIViewController实现了这个方法,返回UIViewController的View的父View; UIWindow返回UIApplication对象;
如果一个响应对象通过这个方法返回YES,那么它成为了第一响应对象,并且可以接收触摸事件和动作消息。子类必须overrider这个方法才可以成为第一响应者。 You must not send this message to a view that is not currently attached to the view hierarchy. The result is undefined.
子类可以override这个方法来更新状态或者执行一些行为,比如高亮选中项。 一个响应对象只有当前响应者可以放弃第一响应者状态,并且新的响应者可以成为第一响应者,才能成为第一响应对象。 [plain] view plain copy
[plain] view plain copy
如果返回NO,拒绝放弃第一响应状态。
如果你override这个方法,必须调用父类的实现[super resignFirstResponder]. Managing Input Views[plain] view plain copy
This property is typically used to replace the system-supplied keyboard that is presented for UITextField and UITextView objects. UITextField和UITextView如果设置了inputView那么在 becomeFirstResponder时不会显示键盘,而现实自定义的inputView;如果设置了inputAccessoryView那么在 becomeFirstResponder时会在键盘的顶端显示自定义的inputAccessoryView。 [plain] view plain copy
This property is typically used to attach an accessory view to the system-supplied keyboard that is presented for UITextField and UITextView objects. [plain] view plain copy
Responding to Touch Events[plain] view plain copy
将消息转发给下一个响应者,将消息发送给父类,不要将消息直接传递给下一个响应者。 如果你override这个方法而没有调用super..,你必须同样override其它响应触摸事件的方法,你要是空实现就好。 默认是不支持多点触摸的,如果想要响应多点触摸,你只要吧UIView的 multipleTouchEnabled 属性设置为YES即可。 [plain] view plain copy
[plain] view plain copy
[plain] view plain copy
当收到touchesCancelled:withEvent:消息的时候需要清除所有通过touchesBegan:withEvent:创建的内容。 Responding to Motion Events[plain] view plain copy
当一个动作开始了和结束了的时候iOS才会通知接收者。it doesn’t report individual shakes. 接收者必须是接收动作事件的第一响应者。 [plain] view plain copy
[plain] view plain copy
Responding to Remote-Control Events[plain] view plain copy
允许传递远程控制事件,必须调用UIApplication的beginReceivingRemoteControlEvents方法;关闭远程控制,调用endReceivingRemoteControlEvents。
Getting the Undo Manager[plain] view plain copy
默认的,每个应用程序的window都有一个undo manager:a shared object for managing undo and redo operations.然而,在响应链中任何对象的类都有它们自己的undo manager,
Validating Commands[plain] view plain copy
YES if the the command identified by action should be enabled or NO if it should be disabled. Returning YES means that your class can handle the command in the current context. |
|