Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine UIAlertViewStyleLoginAndPasswordInput with UIKeyboardTypeEmailAddress

Is there any way of displaying a UIAlertView with Login/Password text fields, so that the keyboard type is of type UIKeyboardTypeEmailAddress?

I use a UIAlertView as follows:

var alertView = new UIAlertView("Login".Translate(), "", null, "Cancel".Translate(), "Login".Translate());
alertView.AlertViewStyle = UIAlertViewStyle.LoginAndPasswordInput;

or, in Objective-C:

UIAlertView *alertView = [[UIAlertView alloc]
                          initWithTitle:@"Title"
                          message:@"Message"
                          delegate:self
                          cancelButtonTitle:@"Cancel"
                          otherButtonTitles:@"Login", nil];
[alertView setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];

but all user names of my app are e-mail addresses, so I'd like to have the keyboard of the login textfield as an e-mail address keyboard, i.e. a UIKeyboardTypeEmailAddress.

Any ideas?

like image 226
cheesus Avatar asked Feb 21 '23 02:02

cheesus


1 Answers

Got it. You can get the textfield of the UIAlertView and set the style there:

alertView.GetTextField(0).KeyboardType = UIKeyboardType.EmailAddress;

Obj-C:

[[alertView textFieldAtIndex:0] setKeyboardType:UIKeyboardTypeEmailAddress];
like image 72
cheesus Avatar answered Mar 05 '23 10:03

cheesus