Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which event handles object becoming/losing first responder status?

I have a UITextView, and I'd like to show UILabel once 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?

like image 292
kolinko Avatar asked Oct 26 '25 01:10

kolinko


1 Answers

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.

like image 141
Rog Avatar answered Oct 27 '25 15:10

Rog



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!