这是我用来分享图片的代码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
答案 0 :(得分:0)
你检查过你的iPad吗?
UIActivityViewController
必须有 ios 6 或以上版本
您可以使用
查看版本 NSString *reqSysVer = @"6.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
{
//use UIActivityViewController here
}