简体   繁体   中英

inputViewController of superview gets called when tapped on subview(UITextView)

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM