1
votes

I have a universal app that uses MFMailComposeViewController to send application feedback. The app contains several other components that users can launch themselves by clicking table view cells that list each component. The components are launched by using the navigation controller's pushViewController: method.

However, with MFMailComposeViewController it is necessary to call presentViewController: from the view controller itself, not from the navigation controller. Once the MFMailComposeViewController is called, the UI suffers from layout issues until it is relaunched.

I suspect this is because MFMailComposeViewController inherits from UINavigationController and pushing another navigation controller onto the stack is causing a conflict. Here is the current intialization for the email form:

MFMailComposeViewController *emailForm = [[MFMailComposeViewController alloc] init];
// configure the form
[self.parent presentViewController:emailMessage animated:YES completion:nil];

I guess the real question here is how to use the MFMailComposeViewController in an app that already contains a navigation controller.

Can anyone offer a suggestion of solution? Thanks!

1
What issues are you actually seeing? I typically find that if you're presenting a MFMailComposeViewController, then any customisations to navigation or status bar need to be reset when that view controller is finished with. You could reset them in view[Will/Did]Appear, or perhaps in the delegate for the MFMailComposeViewController. - rickerbh
I have a similar problem where i am not able to control the Orientation settings on my MFMailComposeViewController - Max

1 Answers

0
votes

When you present the mailComposeViewController, dispatch it on the main queue and the UI constraint issue won't occur. I'm using swift so I have to do this:

dispatch_async(dispatch_get_main_queue()), { self.presentViewController(mailComposeViewController, animated:false, completion:nil) })