This was working OK in iOS7. After upgrading to iOS8 it is strangely not working.
So, if the user has already logged in before, the username is saved and a password is required. Quite simply, I was just inputting the username in the 0 index UITextField
and setting the cursor at the 1 index UITextField
of the UIAlertView
.
Before I just had to set the becomeFirstResponder
to the number 1 index UITextField
in the UIAlertView
. The strange thing is that I can actually set text into the number 1 index UITextField
. So I know I'm accessing the UITextField
correctly still.
Pretty straightforward code.
Here's my code...
- (IBAction)actionTesting:(id)sender {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Login" message:@"" delegate:self cancelButtonTitle:@"Login" otherButtonTitles: nil];
alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
alert.tag = 999;
UITextField *txtUserName = [alert textFieldAtIndex:0];
UITextField *txtPassword = [alert textFieldAtIndex:1];
txtUserName.text = @"";
txtPassword.text = @"";
[alert textFieldAtIndex:1].delegate = self;
[alert show];
}
-(void)didPresentAlertView:(UIAlertView *)alertView{
UITextField *txtUserName = [alertView textFieldAtIndex:0];
UITextField *txtPassword = [alertView textFieldAtIndex:1];
txtUserName.text = @"username";
txtPassword.text = @"password";
[txtPassword becomeFirstResponder];
}
It looks like we have a new UIAlertController
available. I was just hoping to get this working so I didn't have to do any changes to my original code for now.