-1

这是我用来分享图像 vaia facebook 的代码:

NSArray *array = [NSKeyedUnarchiver unarchiveObjectWithData:archive];
UIActivityViewController *activityVC = 
    [[UIActivityViewController alloc] initWithActivityItems:array 
                                      applicationActivities:nil]; 
activityVC.excludedActivityTypes = @[UIActivityTypeAssignToContact, 
                                     UIActivityTypePrint,
                                     UIActivityTypePostToTwitter,
                                     UIActivityTypePostToWeibo,
                                     UIActivityTypeMail,
                                     UIActivityTypeCopyToPasteboard,
                                     UIActivityTypeSaveToCameraRoll];
[self presentViewController:activityVC animated:YES completion:nil];

这在模拟器中运行良好,但是当我在真正的 ipad 3 上对其进行测试时,它会强制关闭说错误

exc_bad_access code=1 address=0*0

在这一行

activityVC.excludedActivityTypes = @[UIActivityTypeAssignToContact, 
                                         UIActivityTypePrint,
                                         UIActivityTypePostToTwitter,
                                         UIActivityTypePostToWeibo,
                                         UIActivityTypeMail,
                                         UIActivityTypeCopyToPasteboard,
                                         UIActivityTypeSaveToCameraRoll];

谁能找到我在这里错过的东西?

编辑部分:

我已经检查了所有内容,并且array不是零。如果我注释掉该行activityVc.exclude....

然后它强制关闭并说

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller
4

1 回答 1

0

你检查过你的 iPad 的操作系统吗?

它必须具有ios 6或更高版本UIActivityViewController 在此处输入图像描述

您可以使用检查版本

   NSString *reqSysVer = @"6.0";
   NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
    if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
      {

       //use UIActivityViewController here
      }
于 2013-08-14T10:56:29.950 回答