Select as input view inside popover

I use popover to show the shape of the table, the size of which corresponds to the iPhone (corresponds to my iPhone application). Inside the table, I have a text box that has a selection set as an input view. When he used this method as an iPad, the collector slides up like an iPad keyboard. Is there anyway to set up the collector to slide within poker just like on an iPhone?

+7
source share
1 answer

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).

+1
source

All Articles