0
我正在Swift中开发一个自定义键盘,我想知道键盘类型何时改变(例如数字或十进制键盘类型)。我相信这应该在textDidChange
或textWillChange
中完成。该方法收到UITextInput
,其中有一个属性keyboardType
。但是,当调用此方法时,该属性似乎始终为nil
,因为即使在输入了不同的输入类型(数字)后,它也从不运行以下代码。为什么在textDidChange中textInput.keyboardType为零?
override func textDidChange(textInput: UITextInput) {
if let inputType = textInput.keyboardType {
//never gets here
deleteKeyboardButton.backgroundColor = UIColor.yellowColor()
}
}