I have an UILabel subclass, conforming UIKeyInputs protocol. But when the keyboard is shown, prediction view is under keyboard keys: Here is the screenshot:
And here is the implementation:
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
}
}
One thing that I did not understand is autocapitalizationType, autocorrectionType and other protocol methods for keyboard appearance are not called.
I hope someone can help. Thank you.