First off, I'm a newbie in programming, please bear with me guys. I'm working on an iOS game built using the Cocos2Dx engine in Xcode. The game has a Share button which is used to share scores. The button seems to work with the iPhone but crashes all the time on an iPad. Xcode points to this line each time it crashes on the iPad:
int retVal = UIApplicationMain(argc, argv, nil, @"AppController");
I figured this issue came about after I changed another piece of code to implement the functionality of the share button. The code which I changed is in the function below.
- (void) displayShare:(NSString*)strText imageIdx:(int)nIdx URL:(NSString*)strURL
{
UIActivityViewController *activityView;
if(nIdx >= 0)
{
NSString* str = [NSString stringWithFormat:@"new-arc-%d-ipad.png", nIdx+1];
UIImage* image = [UIImage imageNamed:str];
activityView = [[UIActivityViewController alloc] initWithActivityItems:@[strText, image, [NSURL URLWithString:strURL]] applicationActivities:nil];
}
else
activityView = [[UIActivityViewController alloc] initWithActivityItems:@[strText, [NSURL URLWithString:strURL]] applicationActivities:nil];
activityView.excludedActivityTypes = @[UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll, UIActivityTypePrint];
// [self.viewController presentViewController:activityView animated:YES completion:nil];
[window.rootViewController presentViewController:activityView animated:YES completion:nil];
[activityView setCompletionHandler:^(NSString *activityType, BOOL completed) {
NSLog(@"completed dialog - activity: %@ - finished flag: %d", activityType, completed);
if(completed)
{
if([activityType isEqualToString: @"com.apple.UIKit.activity.PostToFacebook"] )
{
g_bArchiveMark[19] = true;
AppSettings::setArchieveInfo(19);
}
else if([activityType isEqualToString: @"com.apple.UIKit.activity.PostToTwitter"] )
{
g_bArchiveMark[20] = true;
AppSettings::setArchieveInfo(20);
}
}
}];
The line I changed is this one (which is in the function above):
[window.rootViewController presentViewController:activityView animated:YES completion:nil];
I would like to know why that line works on the iPhone devices but not on the iPad? And how could I resolve it to work on the iPad as well? Maybe an alternative piece code?