[英]Custom Keyboard covers standard inputView
我为标准iOS键盘创建了一个自定义inputView,它在iOS 7和8中都运行得很好。但是当使用第三方自定义键盘时,它覆盖了我创建的inputView。 它会显示自定义inputView一秒钟,并使用自定义键盘视图覆盖它。 我尝试了几种不同的自定义键盘,它们都有同样的问题。
是否可以在任何类型的键盘上使用inputView? 如果可能,该怎么办?
谢谢你的建议!
我遇到了同样的问题,我发现使用由视图控制器管理的视图会导致此问题。 我做了一个简单的演示来说明它:
如下所示, toggleInputView
将创建一个适用于系统键盘和第三方键盘的输入视图,而toggleInputViewController
仅适用于系统键盘。
import UIKit
class CustomInputViewController: UIViewController {
override func viewDidLoad() {
self.view.frame = CGRect(x: 0, y: 0, width: 300, height: 200)
}
}
class ViewController: UIViewController {
var customInputViewController: CustomInputViewController?
@IBOutlet weak var textView: UITextView!
@IBAction func toggleInputView(sender: AnyObject) {
if textView.inputView == nil {
textView.inputView = UIView(frame: CGRect(x: 0, y: 0, width: 300, height: 200))
} else {
textView.inputView = nil
}
self.textView.reloadInputViews()
}
@IBAction func toggleInputViewController(sender: AnyObject) {
if textView.inputView == nil {
if self.customInputViewController == nil {
self.customInputViewController = CustomInputViewController()
}
self.textView.inputView = self.customInputViewController!.view
} else {
self.textView.inputView = nil
}
self.textView.reloadInputViews()
}
}
因此,您可以通过子类UIView
构建输入视图来解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.