Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems using MFMailComposeViewController

I'm trying to set it up so people can email from within my application. I'm referencing this post to do this, but I'm getting these warnings on the build: enter image description here

and then when I run it, it bugs: enter image description here

I'm wondering if I've simply placed the code in the wrong area. Just so you know I have placed

#import <MessageUI/MessageUI.h>

in the header file.

Thanks for the help!


EDIT 1

It seems as if the problem lies within how my ViewController is setup. In fact all my UI code is in a separate object as shown below. This is making it difficult for me to understand which code goes where. Any advice? enter image description here

like image 761
Eric Brotto Avatar asked Dec 21 '22 15:12

Eric Brotto


2 Answers

Add the MessageUI framework into your framework folder and import these classes in your viewController.h:-

#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>

@interface *your controller* : UIViewController <MFMailComposeViewControllerDelegate>
like image 119
Gypsa Avatar answered Jan 04 '23 10:01

Gypsa


Well it looks like your SpeakHereController isn't a UIViewController.

Therefore it can't find the methods for presenting and dismissing the modalViewController. Also you need to implement the MFMailComposeViewControllerDelegate, add it to your viewcontroller.

like image 44
rckoenes Avatar answered Jan 04 '23 10:01

rckoenes