Reputation: 397
If got a rootViewController which display's a UIScrollView full screen. When I tap the UIScrollview, I want to flip the screen and display a settings screen (which also has a second screen, the reason for the navigationController).
I am able to display the settings screen by using the following code in my rootViewController:
self.navController = [[UINavigationController alloc]
initWithRootViewController:self.settingsViewController];
and than:
[self.navController pushViewController:self.settingsViewController animated:YES];
My question is: When I'm done in my settings view, how do I return back to the rootViewController, so the controller class in which I have created the navigation Controller and is therefore not on the stack.
Upvotes: 0
Views: 513
Reputation: 397
I've adopted Apple's solution which they use in the Metronome example.
I'm setting the settingsViewController as the rootViewController for a navigationController. Than I display the navigationController using:
[self presentModalViewController:navController animated:YES];
As per apple's example, I've created a settingsViewControllerDelegate interface which the rootViewController adopts. The interface is not complicated, just a delegate instance var and a callback method (settingsViewControllerDidFinish) which needs to be implemented by rootViewController. In that methode you call:
[self dismissModalViewControllerAnimated:YES];
This way I'm able to have a couple of settings-screens using a navigationController and I'm able to return out of the navigationController back to the rootViewController.
Upvotes: 1