I'm trying to attach a screenshot to my mail in my UIActivityViewController
without the screenshot being saved to my library. Here's my code so far:
-(IBAction)ActivityController:(id)sender {{
NSString *shareString = @"";
UIImage *shareImage = [UIImage imageNamed:@""];
NSURL *shareUrl = [NSURL URLWithString:@""];
NSArray *activityItems = [NSArray arrayWithObjects:shareString,shareImage, shareUrl, nil];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:activityViewController animated:YES completion:nil];
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *exportData = UIImageJPEGRepresentation(image ,1.0);
[mailController addAttachmentData:exportData mimeType:@"image/jpeg" fileName:@"Screenshot.jpeg"];
There is no screenshot attached to the email.
And how do I create an action when I press the cancel button in UIActivityViewcontroller
?