开发者

Popup UIPicker when tapping on UITextField

I need to display/show a Picker when a user taps on a textfield, I mean, it should appear a picker instead of a keyboard. Also, some sort of "done" button above the picker so the user clicks on it and the value from the picker is copied to the textfield and the picker is hidden again.

I've checked many tu开发者_JS百科torials from the web but haven't found anyone that can really help me.

I found a tutorial that pointed me in the right direction but I'm still missing to disappear the keyboard when clicking on the textfield. Dismissing UIPickerView with Done button on UIToolBar by @slev

Any ideas?


If you're not targeting iOS versions older than 3.2, it's easy. You can either assign the UIPickerView as the inputView property of the UITextField and the UIToolbar containing the 'done' button as the inputAccessoryView, or you could make a single UIView that has both the picker and the toolbar as subviews and assign that as the intputView (and leave inputAccessoryView as nil). Either way, this will animate your picker in in place of the normal keyboard when the text field is activated.

More details on this are available in the documentation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜