2

I have UIView Subclass to which I have added a UITextField. I have set this view as my Viewcontroller's top view. In the UIViewSubclass, I have overridden inputViewController getter to provide a custom keyboard.

When I am selecting the UITextField, I would assume the becomeFirstResponder of UITextField is called and I would see the keyboard associated with it. However, Apart from this, inputViewController method on my UIView Subclass also is getting called causing both the textfield's and the UIView's input view getting shown one on top of another. I also do not see canBecomeFirstResponder or becomeFirstResponder getting called on my UIView's subclass. Only inputViewController method is called and the custom keyboard shows up.

Could anyone help me understand why inputViewController is getting called on my UIView's subclass even when it is not becoming first responder.

UPDATE From apple documentation - "An input view is a substitute for system keyboards that is assigned to the inputView property of a text view or a custom view. When there are input views, UIKit might swap out the keyboard even when a text object is first responder, and it might show a keyboard-like input view on the developer's behalf for non-text objects."

So if I understood this correctly, it does make sense for UIResponder to call inputViewController on my UIView subclass but it should ideally have swapped out the textfields keyboard with the inputViewController? Clearly that is not happening here.

user2990765
  • 387
  • 2
  • 3
  • 16

1 Answers1

0

Are you using a UIView subclass specifically to override inputViewController? You may try instead to not do that, but subclass UITextField instead, and then override inputViewController in your UITextField subclass.

auspicious99
  • 3,902
  • 1
  • 44
  • 58
  • I need my UIView to become first responder sometimes and have its own custom keyboard when it becomes first responder. I can't achieve this by subclassing UITextfield. – user2990765 Jan 13 '17 at 04:11