I'm confused about severals first responder points:
- becomeFirstResponder
, does system call – canBecomeFirstResponder
first? Why?- becomeFirstResponder
and – canBecomeFirstResponder
? In what situations they can return different values?– resignFirstResponder
on some object? Does UIApplication
become first responder immediately or is this "token" thrown on some point in the responder chain? Can I call - becomeFirstResponder
on UIApplication
object when I want to get rid of that pilgrim token?Please somebody explain me, how system manages its first responder. What is happening under the hood when some object becomes first responder, what when resigns first responder. What calls does system do... Thank you!
becomeFirstResponder
does call canBecomeFirstResponder
. This is because a responder that returns NO from canBecomeFirstResponder
is not supposed to become the first responder.becomeFirstResponder
will make the receiver actually be the first responder if it succeeds. canBecomeFirstResponder
just checks if the receiver is willing to be the first responder, without actually changing anything. It is possible that becomeFirstResponder
could fail if the current first responder refuses to resign. There may be other situations where becomeFirstResponder
could fail as well.firstResponder
, the system does not assign any particular default in this case.Basically, when something wants to become the first responder the current first responder (if any) is asked to resign, and then the new object becomes the first responder. This may cause the system to display the on-screen keyboard or take some other action. When the first responder resigns, this may similarly cause the system to hide the on-screen keyboard or take some other action.
When a non-touch event comes in, it is first delivered to the UIWindow. The UIWindow delivers it to the first responder. The documentation doesn't seem to specify whether or not UIWindow attempts to handle the event itself (and passes it to UIApplication as usual if it doesn't handle it itself) or just ignores the event if there is no first responder.
See the documentation for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With