简体   繁体   English

点击子视图(UITextView)时,将调用超级视图的inputViewController

[英]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 ,我会假定UITextFieldbecomeFirstResponder被调用,并且我会看到与其关联的键盘。 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上调用canBecomeFirstResponderbecomeFirstResponder 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.

相关问题 调用Superview的UILongPressGestureRecognizer而不是Subview - UILongPressGestureRecognizer of Superview gets called instead of Subview 子视图(UILabel)放置在超级视图(UITextView)中时不遵守约束 - Subview (UILabel) doesn't respect the constraints when placed in superview (UITextView) 在 UITextView 上点击时未调用 UICollectionView didSelectItemAtIndexPath - UICollectionView didSelectItemAtIndexPath not called when tapped on UITextView 移动子视图时移动超级视图-ObjectiveC - Move superview when moving subview - ObjectiveC 在iPhone中向其添加子视图时如何保留超级视图? - How to retain superview when adding a subview to it in iphone? 加载subView时,在超级视图上禁用用户交互 - Disable user interaction on superview when subView is loaded 当两个子视图具有相同的父视图时,根据其他子视图进行居中 - center subview according to other subview when both have the same superview 删除子视图后,从超级视图中删除 - When a subview is removed, remove from superview UIView上的UITapGestureRecognizer及其子视图在点击子视图时一起响应 - UITapGestureRecognizer on UIView and Its Subview Respond Together When Subview Is Tapped MapKit中调用的此灰色弹出窗口到底是什么?点击时会调用什么方法? - What exactly is this grey colored popup called in MapKit & what method gets called when tapped?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM