我有一个 UIView
的子类,符合 UIKeyInput
协议。我想将键盘类型设置为 numberPad
. 不幸的是,设置这个属性没有任何作用。
var keyboardType: UIKeyboardType {
.numberPad
}
编译器用以下描述警告我。
Property 'keyboardType' nearly matches optional requirement 'keyboardType' of protocol 'UITextInputTraits'
因此,我知道这个属性并不是指... UIKeyInput
协议。我在寻找其他协议或类,叫做 UIKeyInput
但我没有发现任何问题。
你有什么建议吗,还有什么原因会导致这个问题?
作为 文件 显示你应该为这个属性提供getter和setter。
optional var keyboardType: UIKeyboardType { get set }