![](/img/trans.png)
[英]UILongPressGestureRecognizer of Superview gets called instead of Subview
[英]inputViewController of superview gets called when tapped on subview(UITextView)
我有我添加了UITextField
UIView Subclass
。 我已將此視圖設置為Viewcontroller的頂視圖。 在UIViewSubclass
,我重寫了inputViewController
getter以提供自定義鍵盤。
當我選擇UITextField
,我會假定UITextField
的becomeFirstResponder
被調用,並且我會看到與其關聯的鍵盤。 但是,除此之外,還調用了我的UIView Subclass
上的inputViewController
方法,導致文本字段和UIView的輸入視圖都顯示在另一個之上。 我也看canBecomeFirstResponder
在我的UIView's subclass
上調用canBecomeFirstResponder
或becomeFirstResponder
。 僅inputViewController
方法,並且顯示自定義鍵盤。
任何人都可以幫助我了解為什么即使不成為inputViewController
響應者,也要在UIView's subclass
上調用inputViewController
。
Apple文檔提供的更新 -“輸入視圖替代了分配給文本視圖或自定義視圖的inputView屬性的系統鍵盤。當存在輸入視圖時,即使第一個文本對象為第一個,UIKit也會換出鍵盤響應程序,它可能會代表開發人員顯示非文本對象的類似鍵盤的輸入視圖。”
因此,如果我正確理解了這一點,那么UIResponder確實有必要在我的UIView子類上調用inputViewController,但是理想情況下它應該已經將textfields鍵盤換成了inputViewController嗎? 顯然,這里沒有發生這種情況。
您是否正在使用專門用於重寫inputViewController的UIView子類? 您可以嘗試不這樣做,而是改用UITextField的子類,然后在UITextField子類中重寫inputViewController。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.