点击 textView 时会发生什么的短视频: https ://www.youtube.com/watch?v=LG_r3iDJKiM
我正在尝试通过 textViewDidBeginEditing 函数在 UITextView 上显示我的自定义键盘,自定义键盘已在 UITextFields 上进行了测试,并且正在按预期工作。现在我试图让相同的键盘与 UITextViews 一起使用。第一次打开应用程序时,第一次点击 textView 会有这种行为,然后当我们点击其他 textView 时,自定义键盘会按预期直接在那里。
我的 TextViewDidBeginEditing 中的当前代码,我尝试更改最后 4 行的顺序但没有成功:
public func textViewDidBeginEditing(_ textView: UITextView) {
keyboard = Keyboard.sharedInstance.keyboardWithType(availableKeyboards.numbers.rawValue, returnKey:textView.returnKeyType, isSecure: false,decimalSeparator:self.decimalSeparatorCharacter, responderClass: self)
inputView.keyboardAppearance = .dark
inputView.hideAssistantBar()
inputView.inputView = keyboard
inputView.reloadInputViews()
}
这将导致上面的视频,我尝试了其他一些方法,但还没有成功:
将一个空的 UIView 设置为 inputView,这仍然会导致苹果键盘很快出现
let view:UIView = UIView()
textView.inputView = view
也尝试过 reloadInputViews 但这也不起作用:
textView.reloadInputViews()
还尝试在主胎面上运行它
DispatchQueue.main.async { }
但没有成功,我不明白为什么即使将 UIView() 设置为 inputView 仍会很快显示苹果键盘。任何正确方向的帮助将不胜感激!
提前致谢!