You cannot do this directly (like inputView). But you can use this simple job:
Replace your UITextField
with a UIButton and connect it to some selector (buttonClicked :). You can use UIButtonTypeCustom
to be able to style it so that it looks like a text field (installation layer bordeColor, borderWidth, cornerRadius
, etc.)
in -(void)buttonClicked:(id)sender
- switch the same UIPickerView that you would use as an input view for the replaced UITextField
. You can do in a regular instance variable, just remember to set the delegate and dataSource. Attach it to the root view (from your UIViewController
show in popover) or even UIWindow
and animate it to or from (switch) depending on whether it has already been shown or not.
text of the refresh button (using [button setTitle:<selected_value> forState:UIControlStateNormal]
) in the UIPickerViewDelegate
: pickerView: didSelect ... atIndex: `method - you can optionally hide the collector here.
I have done this several times, it always works under any circumstances , and you have full control over how and where the collector is displayed without involving the UIResponder
chain.
I did not find a better solution for such special cases (iPad-keyboard also likes to manipulate popovers - this pushes them).
Lukasz
source share