I animate a custom view with a picker subview like how a keyboard appears when activating a UITextField.
Currently I do it by adding my custom view as a subview to the app’s UIWindow. If I add the the custom view as a subview to the current tab bar view controller’s view, the tab bar will cover the picker. Is there a way to animate the custom view as a subview of the current view controller without having the tab bar covering the custom view? What view does the keyboard come up on?
Just a little disclaimer: This is my first post on stackoverflow so if formatting isn’t all fine I’m sorry for that. Also, I’m fairly new to iOS programming as well as to the Objective C language, so I’m definitely not saying this is the way things ‘should’ be done. However, recently I ran into a comparable situation which I solved in a way I think is quite elegant:
To me, it seems like using a UIPickerView could just be the preferred way to enter text into a textfield as opposed to using the regular keyboard. From a user experience point of view, to me that means the UIPickerView should (dis)appear in a similar way as the keyboard as well.
Since iOS 3.2, UITextField supports the inputView property to assign a custom view to be used as a keyboard, which provides a way to display a UIPickerView:
Like that. This will not give you a direct way to dismiss the view since your UIPickerView has no return button, which is why I recommend to use the inputAccessoryView property to display a toolbar with a done button (the bar is just for aesthetics, you might as well just use a UIButton object):
When I reread your question, I noticed that the UIPickerView is just part of the subview. Anyway, this method works for any view so in your case you would set your subview as the UITextField’s inputView.