swiftuikitprotocolsuikeyboardtypeuikeyinput

UIKeyInput keyboard type protocol requirement does not match


I have a UIView subclass which conforms to UIKeyInput protocol. I want to set the keyboard type to numberPad. Unfortunately, setting this property does nothing.

var keyboardType: UIKeyboardType {
    .numberPad
}

Compiler warns me with the following description:

Property 'keyboardType' nearly matches optional requirement 'keyboardType' of protocol 'UITextInputTraits'

Therefore, I know that this property does not refer to the UIKeyInput protocol. I was looking for other protocols or classes called UIKeyInput, but I didn't find any.

Do you have any suggestion what else can cause this issue?


Solution

  • As documentation show you should provide getter and setter for this property.

    optional var keyboardType: UIKeyboardType { get set }