UIAlertView: UIAlertViewStyleSecureTextInput: цифровая клавиатура
В настоящее время я использую этот UIAlertView для создания всплывающего окна входа в систему,
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Restricted"
message:@"Please Enter Code to Enable Fields"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Login"
, nil];
alert.alertViewStyle = UIAlertViewStyleSecureTextInput;
[alert show];
Однако я хотел бы, чтобы ввод текста представлял собой числовую клавиатуру вместо обычной клавиатуры
Есть ли простой способ сделать это, или мне нужно изучить создание пользовательского UIAleartView
Ответы
Ответ 1
Вы можете попробовать это, чтобы изменить тип клавиатуры поля UIAlertView
:
[[alert textFieldAtIndex:0] setDelegate:self];
[[alert textFieldAtIndex:0] setKeyboardType:UIKeyboardTypeNumberPad];
[[alert textFieldAtIndex:0] becomeFirstResponder];
Ответ 2
Прохладный ответ, но для iOS 7 У меня небольшая адаптация
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
[alert show];
[[alert textFieldAtIndex:0] setDelegate:self];
[[alert textFieldAtIndex:0] resignFirstResponder];
[[alert textFieldAtIndex:0] setKeyboardType:UIKeyboardTypePhonePad];
[[alert textFieldAtIndex:0] becomeFirstResponder];
Ответ 3
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];