我正在尝试向我的应用添加共享按钮以共享PDF,我尝试了以下内容:
NSArray *objectsToShare = @[@"http://example.com/ios-game-kit-sample.pdf"];
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
[self presentViewController:controller animated:YES completion:nil];
但是我收到了这个错误:
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'UIPopoverPresentationController (<_UIAlertControllerActionSheetRegularPresentationController: 0x166fb530>) should have a non-nil sourceView or barButtonItem set before the presentation occurs.'
我做错了什么?
我看到了这个解决方案,但我不明白parentView
是什么:
alertController.popoverPresentationController.sourceView = parentView;