0

I'm looking for a library that makes it dead-simple to present a UIPickerView (or other custom view) by having it slide in from the bottom of the screen, like a keyboard or actionsheet. It should support placing a toolbar above the picker (with custom buttons), and it should have options for dismissing the picker (like tapping outside the picker, etc.)

I know how to code this up for any given view controller, but I'm looking for a generic solution that is reusable, with minimal impact on the presenting controller.

Does this exist? I couldn't find one...

TomSwift
  • 39,369
  • 12
  • 121
  • 149

1 Answers1

2

As long as you're not targeting pre-3.2 versions of iOS, you can just use the inputView and inputAccessoryView properties of your UIResponder subclass that needs to use the custom input method. As far as anything else in your code need be concerned, it works exactly like the standard keyboard. If your UIResponder is a UITextField or UITextView, you don't even have to subclass as those classes already redeclare inputView and inputAccessoryView as read-write.

The only drawback is that dismissing the custom input view works exactly like dismissing the standard keyboard, so no built-in support for dismissing just by touching anywhere outside the popup. But on the other hand, any existing solution for doing so with the standard keyboard will work without modification here too. Personally, I usually just put a "Done" button on the UIToolbar used for the inputAccessoryView.

More details on this are available in the documentation. See Customizing the iPhone keyboard for a previous answer with a bit more detail.

Community
  • 1
  • 1
Anomie
  • 92,546
  • 13
  • 126
  • 145
  • I considered this, but sometimes I have need for this when there's not an object that is firstResponder, such as presenting this UI in response to a button click. I guess I could work around that.. – TomSwift Sep 16 '11 at 16:40
  • @TomSwit: There is no reason the button couldn't become the first responder. – Anomie Sep 16 '11 at 20:38