Reputation: 607
The first ViewController in my app subclasses UIImagePickerController and then through the didFinishPickingMediaWithInfo callback, I do the following:
EditViewController *editViewController = [[EditViewController alloc] initWithNibName:@"EditViewController" bundle:nil];
[self pushViewController:editViewController animated:YES];
this ViewController displays properly... Then, through an IBAction, I do the following:
PreviewViewController *previewViewController = [[PreviewViewController alloc] initWithNibName:@"PreviewViewController" bundle:nil];
previewViewController.tempImage = img;
[self.navigationController pushViewController:previewViewController animated:YES];
This view also displays correctly. In this VC I'm trying to use the MFMailComposeViewController for sending an email. When I attempt to push it, I get Pushing a navigation controller is not supported:
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
mailViewController.mailComposeDelegate = self;
[mailViewController setSubject:@"Subject Goes Here."];
[mailViewController setMessageBody:@"Your message goes here." isHTML:NO];
[self.navigationController pushViewController:mailViewController animated:YES];
But when I present it instead:
[self presentModalViewController:mailViewController animated:YES];
The mailViewController appears for only a second and then disappears and I see a black background (but not the previous VC's view) with an empty navbar on top. The app is still running at this point.
What am I doing wrong?
Upvotes: 1
Views: 1746
Reputation: 2862
If you still want to push the mailViewController you can do this (iOS 7 only):
UIViewController *theMailViewController = [[mailViewController viewControllers] lastObject];
[self.navigationController pushViewController:theMailViewController animated:YES];
That way the MailViewController's rootViewController will get pushed into your actual navigationController.
I hope this helps you.
Upvotes: 5