繁体   English   中英

UIDocumentInteractionController 菜单不会关闭(React Native 0.61.5)iOS 13+

[英]UIDocumentInteractionController menu does not dismiss (React Native 0.61.5) iOS 13+

我对用于打开 PDF 文档的 UIDocumentInteractionController 有问题。

此时的问题是,当用户与我点击 Open in {app_name} 操作的菜单交互时,当用户返回应用程序时,菜单本身无法在用户交互后关闭菜单。

此时关闭菜单需要用户在 X 上点击两次才能关闭菜单。

我还尝试在应用程序返回到活动状态时通过在 UIDocumentInteractionController 实例上运行dismissMenuAnimated来动态关闭菜单,但在这种情况下它不起作用,但是如果没有对其进行交互并且调用该方法,它会关闭对话框。

需要注意的是,此问题仅在从未出现过的 iOS 13+ 版本上出现。 在较旧的操作系统上,菜单在交互后按预期关闭。

我们尝试使用此代码而不是我们尝试过的所有 react-native 代码:

    @property (nonatomic, strong) UIDocumentInteractionController *documentInteractionController;
@property (atomic) CGRect rect;

RCT_EXPORT_METHOD(openDocumentInteractionControllerWithFileURL:(NSURL *)fileURL){
    if (!fileURL) {
        // Return NO because there was no valid fileURL.
        return;
    }

    UIViewController *rootCtrl = [[[[UIApplication sharedApplication] delegate] window] rootViewController];

    // Open "Open in"-menu
    self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
    self.documentInteractionController.delegate = self;

    BOOL sucess; // Sucess is true if it was possible to open the controller and there are apps available

    sucess = [self.documentInteractionController presentOpenInMenuFromRect:self.rect inView:rootCtrl.view animated:YES];


    if(!sucess){
        // Inform app that the activity has finished
        // Return NO because the service was canceled and did not finish because of an error.
        // http://developer.apple.com/library/ios/#documentation/uikit/reference/UIActivity_Class/Reference/Reference.html
    }
}

RCT_EXPORT_METHOD(dismissDocumentInteractionController){
    // Hide menu
    [self.documentInteractionController dismissMenuAnimated:YES];
}

但没有成功。

用户在此菜单中进行选择后,您需要关闭交互controller菜单。

你可以在UIDocumentInteractionControllerDelegate这样做:

   - (void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application {

    [self.documentInteractionController dismissMenuAnimated:YES];
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM