ios - How to hide UIPickerView when placed in nib file -


i choose picker view here. working great. when app runs shows up. however, want shown when textfield tapped , before want hidden. country picker subclass of uipickerview , placed inside nib file. please help.

you should follow next steps:

    1. create iboutlet properties in owner class (do not forget add uitextfielddelegate in header file):

@property (weak, nonatomic) iboutlet countrypicker *mypickerview; @property (weak, nonatomic) iboutlet uitextfield *mytextfield; 

    2. connect iboutlets pickerview, textfield in xib. , in viewdidload method add:

self.mytextfield.delegate = self; 

since should implement uitextfield delegate methods. uitextfield protocol reference

    - (void)textfielddidbeginediting:(uitextfield *)textfield     {       self.mypickerview.hidden = no;     } 

this method notifies delegate specified text field became first responder. can use method update delegate’s state information. example, might use method show overlay views should visible while editing.

    - (void)textfielddidendediting:(uitextfield *)textfield     {       self.mypickerview.hidden = yes;     } 

this method called after text field resigns first responder status. can use method update delegate’s state information. example, might use method hide overlay views should visible while editing.

edit1: github sample


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -