I have this problem with popToRootViewControllerAnimated which I could not find a solution for, not even amongst all the questions in this site.
Basically, I have a main tabbar, with a UIViewController in each tab. On one of the tabs, I have a button to move to the next screen (say B). In the B viewcontroller, I have another button to go to the next view controller, say C. What I am trying to accomplish is to go back to A from C with one click. Thats my code:
To get from A to B, I do this:
ExerciseNextScreen *exerciseNextScreen = [[ExerciseNextScreen alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:exerciseNextScreen animated:YES];
Then from B to C, I do this:
ScreenOneExercise *screenOneExercise = [[ScreenOneExercise alloc] initWithNibName:nil bundle:nil];
UINavigationController *screenOneExerciseNav = [[UINavigationController alloc]initWithRootViewController:screenOneExercise];
[self presentModalViewController:screenOneExerciseNav animated:YES];
Now, in C, I do that while trying to get back to A:
- (IBAction)cancelView:(id)sender
{
[self.navigationController popToRootViewControllerAnimated:YES];
}
When getting into the cancelView method, nothing happens. I checked self.navigationController right before this call, and it't not nil.
Any ideas how can I go back to the A view controller? I tried everything in this forum, but with no avail.
Thanks.
the method popToRootViewControllerAnimated
does not work with modal views. You need to call the method dismissModalViewControllerAnimated:
first to dismiss all your modal views. I guess you need to call the method on your controller A to dismiss all modal views at once.
Cheers, anka
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.