Hi Stu, I think this is what you want. It is rather messy, lots of comments here and there.
I should just point out that there is an if statement for iphone and ipad. If you just use the iphone code on an ipad, it will cause a reset problem!
Also the ipad version I think that code got deprecated at IOS 8. So you may want to update that part of the code for IOS 9+? If you have an ipad just test it make sure it is all working. I don't have an ipad, so I can't test it.
Anyway hope it helps.
void ShowShare(String title, String text, String screenshot)
{
String fullPath = BBGame::Game()->PathToFilePath( screenshot );
//NSLog(@"fullPath = %@", fullPath.ToNSString());
UIImage * img = [UIImage imageWithContentsOfFile:fullPath.ToNSString()];
NSArray * objectsToShare = @[text.ToNSString(), img];
UIActivityViewController * activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
//UIActivityTypePostToFacebook
//UIActivityTypePostToTwitter
//UIActivityTypePostToWeibo
//UIActivityTypeMessage
//UIActivityTypeMail
//UIActivityTypePrint
//UIActivityTypeCopyToPasteboard
//UIActivityTypeAssignToContact
//UIActivityTypeSaveToCameraRoll
//UIActivityTypeAddToReadingList
//UIActivityTypePostToFlickr
//UIActivityTypePostToVimeo
//UIActivityTypePostToTencentWeibo
//UIActivityTypeAirDrop
NSArray * excludeActivities = @[UIActivityTypeAirDrop,
//UIActivityTypePrint,
//UIActivityTypeAssignToContact,
//UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList,
UIActivityTypePostToFlickr,
UIActivityTypePostToVimeo];
activityVC.excludedActivityTypes = excludeActivities;
// Where did you get the appDelegate line from?
// modules/brl/native/admob.ios.cpp L56
BBMonkeyAppDelegate *appDelegate=(BBMonkeyAppDelegate*)[[UIApplication sharedApplication] delegate];
//[appDelegate->viewController presentViewController:activityVC animated:YES completion:nil];
// If you use just the following line, it will crash on iPad!
// [appDelegate->viewController presentViewController:activityVC animated:YES completion:^{}];
//if iPhone
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
[appDelegate->viewController presentViewController:activityVC animated:YES completion:nil];
}
//if iPad
else
{
// Change Rect to position Popover
UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:activityVC];
[popup presentPopoverFromRect:CGRectMake(appDelegate->viewController.view.frame.size.width/2, appDelegate->viewController.view.frame.size.height/4, 0, 0)inView:appDelegate->viewController.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
//[img autorelease];
}
|