我想在用户按下返回按钮后将键盘类型从默认更改为数字。 然而,设置keyboardType属性后,什么也没有发生。以编程方式更改iOS上的键盘类型不做任何事情
我的代码:
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
return YES;
}
我已经给自己设定的文本字段委托,并按下返回按钮后,该方法被调用。
编辑:由
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
[textField reloadInputViews];
return YES;
}
http://stackoverflow.com/questions/7301018/programmatically-change-uitextfield-keyboard-type – Rushabh
您可能要试试这个问题发布的解决方案:http://stackoverflow.com/questions/1594346/dynamically-changing-keyboard-type-for-a-uisearchbar – henning77