Search code examples
ios6

UIAlertViewStyleLoginAndPasswordInput


I have been looking for a couple of days now and still cannot figure out how to get the password to verify itself, regardless of what I enter in the username and password field it will always move to the page even if the username/password is not what is defined.

EDIT - When my cancel button is clicked it will return to the page the login is located, but I need to have the password verified, just to clairfy

here is my code

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 1){

        UITableViewController *alertView = [self.storyboard instantiateViewControllerWithIdentifier:@"ADTERM"];
        [self presentViewController:alertView animated:YES completion:nil];
    }

    NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
    if([title isEqualToString:@"Login"])
    {
        UITextField *username = [alertView textFieldAtIndex:0];
        UITextField *password = [alertView textFieldAtIndex:1];
        NSLog(@"Username:Test %@\nPassword:1234567891 %@", username.text, password.text);
    }
}

Solution

  • Use willDismissWithButtonIndex delegate method to verify which button has been pressed and from there do additional steps to see if they can either stay on the same view or if user has been validated load another view. use global variable like isVerified to determine the current state.