Change custom inputView for standard keyboard in iOS

I have a custom inputView for a specific text field and it works well. However, I cannot distinguish how to decline the view and return the normal keyboard. (I have a SWAP button next to TextField.) I tried setting the input textView field to zero, but it did nothing.

I don't need a full user keyboard, but I need more than the kind of accessories above the keyboard, so I'm trying this route. I need about 20 custom buttons in addition to a regular keyboard, and I don't like the idea of ​​a huge accessory that takes up so much space.

I would also prefer not to require the user to initially install a full custom keyboard before using the application.

Thanks so much for any suggestions.

+7
ios swift keyboard
source share
2 answers

I think you will probably have to do this:

  • Call resignFirstResponder on a UITextField
  • After the animation finishes, set inputView to nil
  • Call becomeFirstResponder in a text field

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

+9
source share

In addition to the accepted answer, you can use reloadInputViews() (and this is unlikely to suffer from any animation crashes caused by calling resignFirstResponder, calls to getFirstResponder):

  • yourTextField.inputView = nil;
  • yourTextField.reloadInputViews();

Here's more info at Apple Docs .

+4
source share

All Articles