gpt4 book ai didi

ios - 带有 iOS 11.1.2 的 iphone 上的 UIDocumentInteractionController

转载 作者:可可西里 更新时间:2023-11-01 03:34:50 26 4
gpt4 key购买 nike

当我在装有 iOS 11.1.2 的 iphoneX 上使用 UIDocumentInteractionController 时,它不显示,并以以下身份登录控制台:

[ShareSheet] ERROR: <_UIDICActivityViewController: 0x107075c00> timed out waiting to establish a connection to the ShareUI view service extension.

但相同的代码在其他 iOS 11.1.2 设备上运行正常,只有 iphoneX 无法预览 documentInteraction 菜单。我的代码有问题吗?如果您找到解决方案,请告诉我。

我的代码:

    var doc: UIDocumentInteractionController?

fileprivate func openWithOtherApp(with url: URL) -> Void {
let doc = UIDocumentInteractionController(url: url)
self.doc = doc
doc.delegate = self
DispatchQueue.main.async { [weak self] in
guard let weakSelf = self else {
return
}
if weakSelf.doc?.presentOpenInMenu(from: weakSelf.view.bounds, in: weakSelf.view, animated: true) != true {
Toast(message: "No app on you iPhone can open this file.")
}
}
}

代表:

  extension UniversalPreviewController: UIDocumentInteractionControllerDelegate {

func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
return self
}

func documentInteractionControllerRectForPreview(_ controller: UIDocumentInteractionController) -> CGRect {
return self.view.bounds
}

func documentInteractionControllerViewForPreview(_ controller: UIDocumentInteractionController) -> UIView? {
return self.view
}

func documentInteractionControllerWillBeginPreview(_ controller: UIDocumentInteractionController) {
NSLog("documentInteractionControllerWillBeginPreview")
}

func documentInteractionControllerDidEndPreview(_ controller: UIDocumentInteractionController) {
self.doc = nil
}
}

我最近的测试:

当我使用永久文件 url(将文件拖到项目文件列表中)时,它有效。

  let permanentUrl = Bundle.main.url(forResource: "INBOX24-2.2-resolv", withExtension: "conf")
self.doc = UIDocumentInteractionController.init(url: permanentUrl!)
//permanentUrl:file:///var/containers/Bundle/Application/40F14112-208E-4A97-8214-D55CC8E597C4/xxx.app/INBOX24-2.2-resolv.conf

但是当我更改为将文件存储在应用程序文档目录中的真实代码时,它不起作用,代码如下:

let url = URL.init(fileURLWithPath: storedPath
self.doc = UIDocumentInteractionController.init(url: url)
//url:file:///var/mobile/Containers/Data/Application/9624FFB3-8CB0-437C-A67B-C71AAB314370/Documents/INBOX24-2.2-resolv.conf

最佳答案

我在我的 iPhone 中发现了同样的问题,我只是重新启动了我的 iPhone,它就解决了。

关于ios - 带有 iOS 11.1.2 的 iphone 上的 UIDocumentInteractionController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47867817/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com