![](/img/trans.png)
[英]How can I support the arrow keys on UIWebView with a Bluetooth keyboard under?
[英]Prediction view is under keyboard keys
我有一个UILabel子类,符合UIKeyInputs协议。 但是当显示键盘时,预测视图位于键盘键下:这是屏幕截图:
这是实现:
class CustomLabel: UILabel {
// some implementation, nothing important to effect keyboard.
}
extension CustomLabel: UIKeyInput {
var hasText: Bool {
if let text = self.text {
return text.isEmpty
}
return false
}
func insertText(_ text: String) {
self.text?.append(text)
}
func deleteBackward() {
guard let text = self.text else { return }
self.text = String(text.dropLast())
}
override var canBecomeFirstResponder: Bool {
return true
}
private var autocapitalizationType: UITextAutocapitalizationType {
return .none
}
private var autocorrectionType: UITextAutocorrectionType {
return .no
}
private var spellCheckingType: UITextSpellCheckingType {
return .no
}
private var keyboardType: UIKeyboardType {
return .twitter
}
private var returnKeyType: UIReturnKeyType {
return .done
}
private var keyboardAppearance: UIKeyboardAppearance {
return .default
}
}
我不了解的一件事是没有调用autocapitalizationType,autocorrectionType和其他用于键盘外观的协议方法。
我希望有人能帮帮忙。 谢谢。
对于Swift4
您必须使用UITextInputTraits
作为
@objc var keyboardType: UIKeyboardType = .default
@objc var autocorrectionType: UITextAutocorrectionType = .no
要么
@objc var keyboardAppearance: UIKeyboardAppearance {
get { return .dark }
set(value) {}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.