iosswiftkeyboardinputview

Swap out a custom inputView for the standard keyboard in iOS


I have a custom inputView for a particular textfield, and it works well. However, I cannot discern how to dismiss the view and get the regular keyboard back. (I have a SWAP button right next to the TextField.) I tried setting the textfield's inputView to nil, but that did nothing.

I do not need a full custom keyboard, but I need more than an Accessory view above the keyboard, which is why I am trying this route. I need about 20 custom buttons in addition to the regular keyboard, and I do not like the idea of a huge Accessory view taking up so much space.

I also would rather not require the user to initially install a full custom keyboard before being able to use the app.

Thank you very much for any suggestions.


Solution

  • I think you will probably have to do this:

    1. Call resignFirstResponder on the UITextField
    2. After the animation finishes, set your inputView to nil
    3. Call becomeFirstResponder on the text field

    The keyboard animation duration is sent in the userInfo dictionary on the keyboard presentation notifications.