![](/img/trans.png)
[英]Value of type 'UITextDocumentProxy.Protocol' does not conform to 'UIKeyInput' in coercion
[英]UIKeyInput keyboard type protocol requirement does not match
我有一个符合UIKeyInput
协议的UIView
子类。 我想将键盘类型设置为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 }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.