Ios 目标c键盘类型未更改
我正在尝试更改我正在使用的Ios 目标c键盘类型未更改,ios,objective-c,iphone,Ios,Objective C,Iphone,我正在尝试更改我正在使用的[ReceiveCode setKeyboardType:UIKeyboardTypeNumberPad]的输入字段键盘类型此 - (void)keyboardWasShown:(NSNotification*)aNotification { [redeemCode isFirstResponder]; [redeemCode setKeyboardType:UIKeyboardTypeNumberPad]; } 当我
[ReceiveCode setKeyboardType:UIKeyboardTypeNumberPad]的输入字段键盘类型代码>此
- (void)keyboardWasShown:(NSNotification*)aNotification
{
[redeemCode isFirstResponder];
[redeemCode setKeyboardType:UIKeyboardTypeNumberPad];
}
当我当时无法更改键盘类型时,我使用了redempticode.keyboardType=UIkeyboardtypenumbers和标点符号代码>但是我失败了
- (void)keyboardWasShown:(NSNotification*)aNotification
{
[redeemCode becomeFirstResponder];
redeemCode.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
}
提前感谢移动下一行
redeemCode.keyboardType = UIKeyboardTypeNumberPad;
到您的视图加载
并删除其他两种方法
另外,请检查ReceiveCode是否不是nil
,如果它是您设置的插座,则可能是self。ReceiveCode
问题是您在键盘显示后设置了类型。
在代码前面的某个地方定义适当的键盘类型。
比如:
我做到了。ReceiveCode.keyboardType=UIKeyboardTypeNumberPad;在这种情况下,请确保此属性没有在代码中的其他地方重新定义。或者尝试在UIKeyboardWillShowNotification观察者的处理程序中设置它
UITextField *tf = //textfield allocation
tf.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
......
[tf becomeFirstResponder];