【发布时间】:2017-10-02 18:33:53
【问题描述】:
在 iOS 11 中,我的应用程序无法将 PDF 共享给另一个第三方应用程序。它会显示共享表,但是当我选择在其他(第三方)应用程序中打开它时,它只会关闭共享表并什么都不做。
我已经确认的事情:
- willBeginSending 和 didEndSending 的委托方法都被调用
- 打开邮件或便笺等第一方应用可以正常工作
- 文档选择器仍在内存中
- 呈现预览效果很好,但预览中的分享按钮仍然无法打开第三方应用
- 我也尝试过使用
UIActivityViewController。共享 URL 会产生相同的行为。共享原始数据可让您“创建 PDF”,然后共享该 PDF 确实有效(但用户体验很糟糕)。
有其他人经历过这种情况或对如何解决它有任何想法吗?
这是显示问题的示例应用程序的完整代码。我在一个新的“单一视图”应用程序中创建了它。故事板只有两个按钮连接到这两个动作。
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)
【问题讨论】:
标签: ios swift uikit ios11 uidocumentinteraction