Which event handles object becoming/losing first responder status?
I have a UITextView, and I'd like to show UILabel 开发者_如何学JAVAonce it receives First Responder status, and hide UILabel when UITextView loses it.
What action handles becoming/losing first responder? Or perhaps there is a better way to display UILabel only when UITextView has focus?
There is also the UITextFieldDelegate methods available to use.
(BOOL)textFieldShouldEndEditing:(UITextField *)textField;
(void)textFieldDidEndEditing:(UITextField *)textField;
These will be called before and after the UITextField loses the first responder status.
UIView is a subclass of UIResponder. Your view will be sent a -(BOOL)becomeFirstResponder
when it becomes first responder and -(BOOL)resignFirstResponder
when it loses it. You can also perform some processing before both of these events from –(BOOL)canBecomeFirstResponder
and –(BOOL)canResignFirstResponder
. All of these methods are defined on UIResponder.
In all cases, assuming you do want to become (or resign) first responder, you should return YES to these messages.
精彩评论