Problems Using MFMailComposeViewController

I am trying to configure it so that people can send messages from my application. I refer to this post to do this, but I get these warnings in the assembly: enter image description here

and then when I started it, it mistakenly: enter image description here

I am wondering if I just put the code in the wrong place. Just so you know what I posted

#import <MessageUI/MessageUI.h> 

in the header file.

Thanks for the help!


EDIT 1

It seems that the problem is how my ViewController is configured. In fact, all of my user interface code is in a separate object, as shown below. This makes it difficult for me to understand which code goes there. Any advice? enter image description here

+4
source share
4 answers

Well, it looks like your SpeakHereController is not a UIViewController.

Therefore, he cannot find methods to represent and reject the modalViewController. You also need to implement MFMailComposeViewControllerDelegate , add it to your view manager.

+3
source

Add a MessageUI structure to your framework folder and import these classes into your viewController.h: -

 #import <MessageUI/MessageUI.h> #import <MessageUI/MFMailComposeViewController.h> @interface *your controller* : UIViewController <MFMailComposeViewControllerDelegate> 
+8
source

Here is the code

 #import <UIKit/UIKit.h> #import <MessageUI/MFMailComposeViewController.h> @interface tempsend : UIViewController<MFMailComposeViewControllerDelegate> 

//. m file code

 MFMailComposeViewController *picmail = [[MFMailComposeViewController alloc] init]; picmail.mailComposeDelegate = self; [picmail setSubject:@"Exporting DDT file"]; // Set up recipients [picmail setToRecipients:[NSArray arrayWithArray:aray_emailid]]; [picmail setMessageBody:emailBody isHTML:NO]; [self presentModalViewController:picmail animated:YES]; [picmail release]; 

Regards, Shyam

+1
source

Add MFMailComposeViewControllerDelegae to SpeakHereController.h

And use

[controlle presentModalViewController:controller animated:YES];

Instead

[self presentModalViewController:controller animated:YES];

Same for

[controlle dismissModalViewControllerAnimated:YES];

Instead

[self dismissModalViewControllerAnimated:YES];

-1
source

All Articles