UIActivityViewController在iOS 8的iPad上崩溃

309

我目前正在使用Xcode 6(Beta 6)测试我的应用程序。 UIActivityViewController在iPhone设备和模拟器上运行良好,但在iPad模拟器和设备(iOS 8)上崩溃,以下是日志:

Terminating app due to uncaught exception 'NSGenericException', 
reason: 'UIPopoverPresentationController 
(<_UIAlertControllerActionSheetRegularPresentationController: 0x7fc7a874bd90>) 
should have a non-nil sourceView or barButtonItem set before the presentation occurs.

我正在使用以下代码,适用于iPhone和iPad,可同时在iOS 7和iOS 8上使用。

NSData *myData = [NSData dataWithContentsOfFile:_filename];
NSArray *activityItems = [NSArray arrayWithObjects:myData, nil];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:nil applicationActivities:nil];
activityViewController.excludedActivityTypes = @[UIActivityTypeCopyToPasteboard];
[self presentViewController:activityViewController animated:YES completion:nil];

我在我的另一个应用程序中也遇到了类似的崩溃。您能否指导我?iOS 8中的UIActivityViewController是否有任何更改?我已经检查过,但没有发现任何更改。


以下是关于编程的内容,请将其翻译为中文。请仅返回已翻译的文本:答案下面测试短语的成语。您应该使用@Galen的答案,它不会。 - doozMen
21个回答

-5

如果你正在使用Swift为iPad开发,请小心,它在调试时可能运行良好,但在发布时会崩溃。为了使其能够与TestFlight和AppStore一起使用,请在发布时使用-none禁用Swift的优化。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接