I'm using Xcode 7 and when I test the code below, it works perfectly on my iPhone on iOS 8 but when I run it on the iOS 9 simulator, it becomes very glitchy. The iOS 9 simulator shows the pop up options but when I click on mail, I don't see the image or text and when I try to edit the mail through the simulator, I see "MailCompositionService quit unexpectedly" with this error in my log:
viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}
Also, when I test on my iPhone with iOS 8 I get this:
LaunchServices: invalidationHandler called
Here's the code I used:
NSString *texttoshare = [NSString stringWithFormat:@"I just scored %li on the game",(long)HighScoreNumber];;
UIImage *imagetoshare = [UIImage imageNamed:@"wallpaper8.png"];
NSArray *activityItems = @[texttoshare, imagetoshare];
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
//if iPhone
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
[self presentViewController:controller animated:YES completion:nil];
}
//if iPad
else {
// Change Rect to position Popover
UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:controller];
[popup presentPopoverFromRect:CGRectMake(self.view.frame.size.width/2, self.view.frame.size.height/4, 0, 0)inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}