This worked fine in iOS7. After upgrading to iOS8, this strangely doesn't work.
So, if the user has already registered earlier, the username is saved and a password is required. Simply put, I just entered the username at index 0 of UITextField and set the cursor to 1 index of UITextField UIAlertView .
Before I just needed to set becomeFirstResponder to index 1 of UITextField in UIAlertView . The strange thing is that I can actually set the text to index number 1 of UITextField . So I know that I get to UITextField .
Pretty simple code.
Here is 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]; }
Looks like we have a new UIAlertController . I was just hoping to get this working, so I didn't need to make any changes to the source code.
source share