UIAlertView: UIAlertViewStyleSecureTextInput: Numeric keyboard

和自甴很熟 提交于 2019-12-01 02:29:44
Abhishek Singh

You can try this to change the keyboard type of the UIAlertView's field:

[[alert textFieldAtIndex:0] setDelegate:self];
[[alert textFieldAtIndex:0] setKeyboardType:UIKeyboardTypeNumberPad];
[[alert textFieldAtIndex:0] becomeFirstResponder];

Cool answer but for iOS 7 I have a little adaptation

alert.alertViewStyle = UIAlertViewStylePlainTextInput;
[alert show];
[[alert textFieldAtIndex:0] setDelegate:self];
[[alert textFieldAtIndex:0] resignFirstResponder];
[[alert textFieldAtIndex:0] setKeyboardType:UIKeyboardTypePhonePad];
[[alert textFieldAtIndex:0] becomeFirstResponder];
 UIAlertView *alertView1 = [[UIAlertView alloc] initWithTitle:@"Enter File Number" message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
        alertView1.alertViewStyle = UIKeyboardTypePhonePad;
        myTextField = [alertView1 textFieldAtIndex:0];
        myTextField.keyboardType=UIKeyboardTypeNumberPad;
        [alertView1 setTag:3];
        [alertView1 show];
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!