【发布时间】:2020-11-09 18:50:12
【问题描述】:
以下代码在 iOS 13.5.1 上的 iPhone 和 iOS 12.4.7 上的 iPad 上运行良好,但在 iOS 13.5.1 上的 iPad 上触发时没有任何反应:
- (void)notificationFired:(NSNotification *)notification {
if (notification != (id)[NSNull null] && [[notification name] isEqualToString:@"OpenActionSheet"]) {
NSString *path = [notification userInfo][@"path"];
printf("Received path: %s", path.UTF8String);
NSURL *url = [NSURL fileURLWithPath:path];
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:@[url] applicationActivities:nil];
[controller setCompletionWithItemsHandler:^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) {
printf("%s", "Share sheet closed");
UnitySendMessage("ShareListener", "Complete", path.UTF8String);
}];
if (IDIOM == IPAD)
controller.modalPresentationStyle = UIModalPresentationPopover
[self.window.rootViewController presentViewController:controller animated:YES completion:nil];
if (IDIOM == IPAD) {
UIPopoverPresentationController *popover = controller.popoverPresentationController;
popover.sourceView = self.window.rootViewController.view;
}
}
}
我也试过
if ([controller respondsToSelector:@selector(popoverPresentationController)])
controller.popoverPresentationController.sourceView = self.rootView;
[self.window.rootViewController presentViewController:controller animated:YES completion:nil];
而不是 IDIOM == IPAD 块,但结果相同。我错过了什么?
【问题讨论】:
标签: ios ipad ios13 uiactivityviewcontroller