[英]inputViewController of superview gets called when tapped on subview(UITextView)
I have UIView Subclass
to which I have added a UITextField
. 我有我添加了
UITextField
UIView Subclass
。 I have set this view as my Viewcontroller's top view. 我已将此视图设置为Viewcontroller的顶视图。 In the
UIViewSubclass
, I have overridden inputViewController
getter to provide a custom keyboard. 在
UIViewSubclass
,我重写了inputViewController
getter以提供自定义键盘。
When I am selecting the UITextField
, I would assume the becomeFirstResponder
of UITextField
is called and I would see the keyboard associated with it. 当我选择
UITextField
,我会假定UITextField
的becomeFirstResponder
被调用,并且我会看到与其关联的键盘。 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. 但是,除此之外,还调用了我的
UIView Subclass
上的inputViewController
方法,导致文本字段和UIView的输入视图都显示在另一个之上。 I also do not see canBecomeFirstResponder
or becomeFirstResponder
getting called on my UIView's subclass
. 我也看
canBecomeFirstResponder
在我的UIView's subclass
上调用canBecomeFirstResponder
或becomeFirstResponder
。 Only inputViewController
method is called and the custom keyboard shows up. 仅
inputViewController
方法,并且显示自定义键盘。
Could anyone help me understand why inputViewController
is getting called on my UIView's subclass
even when it is not becoming first responder. 任何人都可以帮助我了解为什么即使不成为
inputViewController
响应者,也要在UIView's subclass
上调用inputViewController
。
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." Apple文档提供的更新 -“输入视图替代了分配给文本视图或自定义视图的inputView属性的系统键盘。当存在输入视图时,即使第一个文本对象为第一个,UIKit也会换出键盘响应程序,它可能会代表开发人员显示非文本对象的类似键盘的输入视图。”
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? 因此,如果我正确理解了这一点,那么UIResponder确实有必要在我的UIView子类上调用inputViewController,但是理想情况下它应该已经将textfields键盘换成了inputViewController吗? Clearly that is not happening here.
显然,这里没有发生这种情况。
Are you using a UIView subclass specifically to override inputViewController? 您是否正在使用专门用于重写inputViewController的UIView子类? You may try instead to not do that, but subclass UITextField instead, and then override inputViewController in your UITextField subclass.
您可以尝试不这样做,而是改用UITextField的子类,然后在UITextField子类中重写inputViewController。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.