How can I send emails from my custom UIActivity class?
I made a costume UIActivity class. I like to send emails with attachments
with the class, but I can't send emails, or present any ViewControllers
from the class. I am trying to present the Mail ViewController with this:
- (void)prepareWithActivityItems:(NSArray *)activityItems
{
NSString *subject = [NSString stringWithFormat:@"%@", [self.filePath
lastPathComponent]];
NSString *messageBody = [NSString stringWithFormat:@"%@ was extracted
with @FilyForiOS, visit", [self.filePath lastPathComponent]];
NSData *attachment = [NSData dataWithContentsOfFile:self.filePath];
MFMailComposeViewController *mc = [[MFMailComposeViewController alloc]
init];
mc.mailComposeDelegate = self;
[mc setSubject:subject];
[mc setMessageBody:messageBody isHTML:NO];
[mc setToRecipients:nil];
[mc addAttachmentData:attachment mimeType:[[self.filePath
lastPathComponent] pathExtension] fileName:[self.filePath
lastPathComponent]];
[self presentViewController:mc animated:YES completion:nil]; // Here
is the error: No visible @interface for 'MailTo' declares the selector
'presentViewController:animated:completion:'
}
Can anyone tell me how I can present a ViewController from this class?
No comments:
Post a Comment