UIDocumentInteractionController.present返回true,但不显示

时间:2019-06-09 15:39:18

标签: ios swift uidocumentinteraction

我有一个iOS Web应用程序,使用HTML5和WKWebView生成文件(例如图像,pdf或epubs),将它们保存在本地(保存到iPad上的temp dir),然后应该为用户提供分享它。我使用UIDocumentInteractionController呈现预览或打开视图,以便用户可以决定如何共享新资源。此过程对于图像和pdf来说效果很好,但是对于epub,即使documentInteractionController.presentOpenInMenu(from: self.view.frame, in: self.view, animated: true)返回true,也不会显示本机共享对话框。

我的epub有效。我可以通过iOS Mail打开相同的文件。

这是代码的相关部分。有什么想法吗?

//url is a file url of a locally stored epub file
func share(url: URL) {

        DispatchQueue.main.async {
            self.documentInteractionController.url = url;

            //setting this doesn't seem to make a difference 
            //documentInteractionController.uti = "org.idpf.epub-container";
            self.documentInteractionController.name = url.localizedName ?? url.lastPathComponent;

            let success = self.documentInteractionController.presentOpenInMenu(from: self.view.frame, in: self.view, animated: true); //no dialog is shown
            print(success); //always true, even though dialog is not shown
        };


        //tried this, but also doesn't work
        //documentInteractionController.presentPreview(animated: true);
    }

0 个答案:

没有答案