Using MFMailComposeViewController in a storyboard does not work

In the storyboard, I can configure segue from the button to the UIViewController and make it visible. It works great. However, when I change the class in the storyboard from UIViewController to MFMailComposeViewController , it does not work at all. All that appears is the navigation bar at the top, and the rest of the display is filled with black. Am I taking the wrong approach?

+6
source share
2 answers

I had a similar problem with ABPeoplePickerNavigationController and I could not understand what the problem was. You can either

  • Go back to IBAction and instantiate the MFMailComposeViewController yourself and show it.

  • If you want to use Storyboards, which seems to me desirable, you can create a wrapper class that internally creates an instance of MFMailComposeViewController and then acts as a proxy object and thus distributes viewDid*** and viewWill*** -methods to to the wrapped class, as well as returning the wrapped VC view readonly view property ... you get the idea.

+2
source

In addition to Besi's answer:

  •  
  •  
  • Subclass MFMailComposeViewController and override the initWithCoder: .

Example:

 -(id)initWithCoder:(NSCoder *)aDecoder { return [super init]; } 

Then it will work with dropdowns, but I think that your exits / tags / other definitions from the storyboard scene will not be applied (you need to configure the mail composer inside your prepareForSegue:sender: method.

+2
source

Source: https://habr.com/ru/post/904927/


All Articles