Task: I have a navigation controller that pushes a modalview, called login. This login view has a button that pushes another modalview, called signup. If a user signs up the the signup modal AND the login modal should dismiss. I have created an nsnotification within the login view that waits for a post from the signup submission action.
Problem The login receives the notification, but does not dismiss the login view. I know that the method runs, because an NSLog fires.
Login viewDidLoad
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dismiss) name@"SignedUp" object nil];
Login dismiss
NSLog(@"Dismiss"); // this fires
[self dismissModalViewControllerAnimated: YES];
Signup method (Child Controller)
[self dismissModalViewControllerAnimated: YES];
[[NSNotificationCenter defaultCenter] postNotificationName:@"SignedUp" object:[self parentViewController]];
I have also tried this after calling dismiss in the signup method
[self.parentViewController dismissModalViewControllerAnimated:YES];
Edit I'm not pushing these controllers. I am using presentModalViewController
Why are you dismissing them one at a time, if you intend to dismiss the entire stack ? This might not be a problem with Notifications. You can just pop the entire stack using
[[[self parentViewController] parentViewController] dismissModalViewControllerAnimated:YES];
And then if you wish to show it again, Just make it the presentModalViewController
again.
I am sure you can get a lot of input through https://stackoverflow.com/search?q=Dismiss+multiple+modal+controllers