How to make UIPickerView that appears if I click on UITextField?

How can I create a UIPickerView that appears when I select a TextField, and its input goes into the TextField if I select a UIPickerView value?

How to do it? Do you have an example of this?

+4
source share
2 answers

Please take a look at this example http://www.techotopia.com/index.php/An_iOS_4_iPhone_UIPickerView_Example

First you can hide the picker.hidden = YES collector; in your viewdidload method and to display it when you touch the text field, you can write picker.hidden = NO; inside uitextfielddidstartediting. Thanks.

+1
source

Create a UIPickerView and set it as the inputView your text box. It will then be displayed on the screen for you when you start editing the text box. The delegate methods of the collector view can be used to update the value of the text field.

You will also want to create a toolbar using the "Finish" button and set it as inputAccessoryView - this will allow you to remove the collector when you select your value. Again, this will automatically appear above the selection view when the text box starts editing.

+2
source

All Articles