我目前正在使用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是否有任何更改?我已经检查过,但没有发现任何更改。