【发布时间】:2020-06-06 19:54:56
【问题描述】:
我正在尽可能使用 SwiftUI 创建一个新的 iOS 应用程序。但是,我希望能够生成包含一些数据的 PDF。 在没有 swiftUI 的类似项目中,我可以做到这一点
let docController = UIDocumentInteractionController.init(url: "PATH_TO_FILE")
docController.delegate = self
self.dismiss(animated: false, completion: {
docController.presentPreview(animated: true)
})
只要在视图控制器的其他地方我有这个:
func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
return self
}
我可以走了。 我无法解决的是如何将其应用于 UIViewControllerRepresentable 并让它在 SwiftUI 中工作。我的 UIViewControllerRepresentable 是否应该以成为 UIViewController 为目标?然后如何设置委托和presentPreview?这会像我的标准 iOS 应用程序那样覆盖任何视图并在我的 SwiftUI 应用程序上全屏显示吗? 谢谢
【问题讨论】:
标签: ios swift iphone uikit swiftui