gpt4 book ai didi

ios - UIDocumentInteractionController 不会在 iOS 11 中打开其他应用程序

转载 作者:搜寻专家 更新时间:2023-10-31 08:16:11 26 4
gpt4 key购买 nike

我的应用程序将 PDF 共享到另一个第三方应用程序的功能在 iOS 11 中已损坏。它显示了共享表,但是当我选择在不同的(第三方)应用程序中打开它时,它只是关闭了共享表并且什么都不做。

我已经确认的事情:

  • willBeginSending 和 didEndSending 的委托(delegate)方法都被调用
  • 打开第一方应用程序(如邮件或备忘录)效果很好
  • 文档选择器仍在内存中
  • 呈现预览效果很好,但预览中的共享按钮仍然无法打开第三方应用
  • 我也尝试过使用 UIActivityViewController。共享 URL 会产生相同的行为。共享原始数据允许您“创建 PDF”,然后共享该 PDF 确实有效(但用户体验很糟糕)。

有没有其他人遇到过这种情况或对如何解决它有任何想法?

这是显示问题的示例应用程序的完整代码。我在一个新的“单一 View ”应用程序中创建了它。 Storyboard只有两个按钮连接到两个 Action 。

class ViewController: UIViewController {
var docController: UIDocumentInteractionController!

@IBAction func open(sender: UIButton) {
// self.docController.presentPreview(animated: true)
self.docController.presentOptionsMenu(from: sender.frame, in:self.view, animated:true)
}

@IBAction func check() {
print(self.docController)
}

override func viewDidLoad() {
super.viewDidLoad()

let url = Bundle.main.url(forResource: "OrderForm", withExtension: "pdf")!
self.docController = UIDocumentInteractionController(url: url)
self.docController.delegate = self
}
}

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

func documentInteractionController(_ controller: UIDocumentInteractionController, willBeginSendingToApplication application: String?) {
print("will begin")
}

func documentInteractionController(_ controller: UIDocumentInteractionController, didEndSendingToApplication application: String?) {
print("did end")
}
}

我还向 Apple 提交了一个错误(问题 ID:34772214)

最佳答案

问题是我试图将 URL 共享到应用程序包内的文件。似乎 Apple 的应用程序有权访问该 URL,但第三方应用程序没有。我解决了这个问题,首先将资源复制到缓存目录,然后使用该缓存目录 URL 进行共享。

关于ios - UIDocumentInteractionController 不会在 iOS 11 中打开其他应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46531572/

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