我想在用戶按下返回按鈕後將鍵盤類型從默認更改爲數字。 然而,設置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