// when i click the button i want an alert view to appear and then entring the login details , if the details are correct then move to next view else not. how to do this ?
// now when i click on the button alert view appears when myButton method ends. how to control the flow ?
- (IBAction)myButton:(id)sender
{
flag= [self alertview];
if (flag)
{
SecondViewController *svc =[self.storyboard instantiateViewControllerWithIdentifier:@"vinay"];
[svc setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentViewController:svc animated:YES completion:nil];
}
}
-(int)alertview
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Login"
message:[NSString stringWithFormat:@"Enter Login ID and Password:"]
delegate:self cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
flag=1;
[alert setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
[alert show];
return flag;
}
What I have done to solve this is as below :
UIAlertViewDelegateprotocol in your .h fileUIAlertView. Method isalertView:clickedButtonAtIndex:.NSString *pass = [alertView textFieldAtIndex:0].text;code. (Here the 0 is the first textbox)Enjoy coding 🙂