繁体   English   中英

目标c keyboardType不变

[英]Objective c keyboardType not change

我尝试使用[redeemCode setKeyboardType:UIKeyboardTypeNumberPad];来更改我输入的键盘类型[redeemCode setKeyboardType:UIKeyboardTypeNumberPad]; 这个

- (void)keyboardWasShown:(NSNotification*)aNotification

    {
        [redeemCode isFirstResponder];
        [redeemCode setKeyboardType:UIKeyboardTypeNumberPad];
    }

当我当时无法更改键盘类型时,我使用了redeemCode.keyboardType = UIKeyboardTypeNumbersAndPunctuation; 但是我失败了。

  - (void)keyboardWasShown:(NSNotification*)aNotification
    {
        [redeemCode becomeFirstResponder];
        redeemCode.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
    }

提前致谢

移动以下行

   redeemCode.keyboardType = UIKeyboardTypeNumberPad;

到您的viewDidLoad并删除其他2种方法

还要检查一下redeemCode是否为nil ,如果它已经设置了出口,则可能应该是self.redeemCode

问题是在显示键盘之后,U会设置类型。 在代码的较早位置定义适当的键盘类型。 喜欢:

UITextField *tf = //textfield allocation
tf.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
......
[tf becomeFirstResponder];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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