将UIAlertViewStyleLoginAndPasswordInput与UIKeyboardTypeEmailAddress结合使用

che*_*ica 4 email iphone login xamarin.ios ios

有没有办法显示一个UIAlertView登录/密码文本字段,以便键盘类型是类型UIKeyboardTypeEmailAddress

我使用UIAlertView如下:

var alertView = new UIAlertView("Login".Translate(), "", null, "Cancel".Translate(), "Login".Translate());
alertView.AlertViewStyle = UIAlertViewStyle.LoginAndPasswordInput;
Run Code Online (Sandbox Code Playgroud)

或者,在Objective-C中:

UIAlertView *alertView = [[UIAlertView alloc]
                          initWithTitle:@"Title"
                          message:@"Message"
                          delegate:self
                          cancelButtonTitle:@"Cancel"
                          otherButtonTitles:@"Login", nil];
[alertView setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
Run Code Online (Sandbox Code Playgroud)

但我的应用程序的所有用户名都是电子邮件地址,所以我想将登录文本字段的键盘作为电子邮件地址键盘,即a UIKeyboardTypeEmailAddress.

有任何想法吗?

che*_*ica 8

得到它了.您可以获取该文本域UIAlertView并在其中设置样式:

alertView.GetTextField(0).KeyboardType = UIKeyboardType.EmailAddress;
Run Code Online (Sandbox Code Playgroud)

OBJ-C:

[[alertView textFieldAtIndex:0] setKeyboardType:UIKeyboardTypeEmailAddress];
Run Code Online (Sandbox Code Playgroud)