ios - How to set the UIView become firs tResponder? -


i learning uiresponder now. wrote test code. in code want let uiview become first responder, failed. test steps are:

  1. create uiview in storyboard.
  2. created class extends uiview view, , override methods canbecomefirstresponder: , becomefirstresponder return yes.

  3. in method of view controller's viewdidappear: method, test it:

    - (void) viewdidappear:(bool)animated {     [self.viewd becomefirstresponder];     nslog(@"%d ", [self.viewd isfirstresponder]); } 

the result of isfirstresponder no.

i have no idea why. can me? thanks.

becomefirstresponder notifies receiver become first responder in window. yes if receiver accepts first-responder status or no if refuses status. default implementation returns yes, accepting first responder status.

a responder object becomes first responder if current responder can resign first-responder status (canresignfirstresponder) , new responder can become first responder.

in case view refuses status that's why no every time.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -