I have a tab bar + navigation based app and I’d like to launch two views back to back from the right side navigation button of the main UIViewController without too many obvious looking transitions. I’m having trouble figuring out the right way to structure and contain such a navigation scheme.
The first view/controller I need to show is the UIImagePickerController, which has to be shown as modal. If you try to push it onto a UINavigationController, you’ll get an exception. As soon as the picker is dismissed, I want to show a child UIViewController. When this child controller is dismissed, I’ll go back to showing my main UIViewController with the tabs.
Here’s how I have it structured now:
Tab Bar
-> (tab 1) UINavigationController -> UIViewController (main content for tab 1)
-> (tab 2) UINavigationController -> UIViewController (main content for tab 2)
MainContent1Controller:
- (void)onNavigationItemTapped {
// Launch the picker to take pictures
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
// configure picker options including:
picker.delegate = self;
[self presentModalViewController:picker animated:YES];
[picker release];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Process the photo taken
// unlink this view controller as the delegate
picker.delegate = nil;
// Dismiss the UIImagePickerController
[self dismissModalViewControllerAnimated:YES];
// Create the 2nd controller and show - this doesn't work and the child controller is not visible for some reason
ChildController *child = [[ChildController alloc] initWithNibName:...];
[self presentModalViewController:child animated:YES];
[child release];
}
Any suggestions?
You should probably do this,
This way you add
childto the navigation hierarchy and dismiss the image picker. A single animation will show the image picker being dismissed to revealchildcontroller.