i’ve a login view presented as a ModelViewController and i have a register view presented as a NavigationControlloer on top of it:
Login (ModelViewController)
—->Register(NavigationController)
i’m presenting the Register view(CreateAccount) at the Loginview as follow:
createAccount= [[CreateAccount alloc] initWithNibName:@"CreateAccount" bundle:nil];
navController = [[UINavigationController alloc] initWithRootViewController:createAccount];
UIBarButtonItem *cancelButtun=[[UIBarButtonItem alloc]initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(HideMe)];
UIBarButtonItem *registerButtun=[[UIBarButtonItem alloc]initWithTitle:@"Register" style:UIBarButtonItemStyleBordered target:self action:@selector(Register)];
createAccount.navigationItem.leftBarButtonItem = cancelButtun;
createAccount.navigationItem.rightBarButtonItem=registerButtun;
createAccount.title=@"Create Account";
[self presentModalViewController:navController animated:YES];
the login controller has the NSURLConnectionDelegate for booth the login and the register.
when registration finishs i simply call the
[self dismissModalViewControllerAnimated:YES];
which will dismiss the registration view only.
i want to dismiss the login view also so i can go back to my main application.
Check out my answer to a similar question here: Dismissing ModalViewController of ModalViewController
I am using pretty much the same thing as you in my app, and this solution works for me. Please be sure to read the comments as well, since one of the references changed with iOS5.
Edit:
In order to dismiss a modal view that is presented over another modal view, you have to call dismissModalViewControllerAnimated: on the parent of the parent.
iOS <5.0
iOS 5.0+ (must change all references to parentViewController to presentingViewController)