繁体   English   中英

UIKeyInput 键盘类型协议要求不匹配

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM