admin管理员组文章数量:1122832
I am trying to record the current screen in my SwiftUI app.
The screen record start in the
.onAppear { }
Then I stop the record once all the recording has done.
However when I try to show it the finished recording in a
.sheet(isPresented: $showPreview, onDismiss: {
// Dismiss action
}, content: {
// Content
rpView
})
I get the blank sheet.
But when I do the following
if showPreview { rpView }
The recording shows on the screen. Not like the .sheet
shows on the screen.
I want to show it how the .sheet
shows the view on the screen.
How can I do it? Or is it not possible ?
This is how my UIViewControllerRepresentable looks like.
struct RPPreviewView: UIViewControllerRepresentable {
typealias UIViewControllerType = RPPreviewViewController
let rpPreviewViewController: UIViewControllerType
@Binding var isShow: Bool
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
func makeUIViewController(context: Context) -> RPPreviewViewController {
rpPreviewViewController.previewControllerDelegate = context.coordinator
rpPreviewViewController.modalPresentationStyle = .pageSheet
return rpPreviewViewController
}
func updateUIViewController(_ uiViewController: RPPreviewViewController, context: Context) { print(#function) }
class Coordinator: NSObject, @preconcurrency RPPreviewViewControllerDelegate {
var parent: RPPreviewView
init(_ parent: RPPreviewView) {
self.parent = parent
}
@MainActor func previewController(_ previewController: RPPreviewViewController, didFinishWithActivityTypes activityTypes: Set<String>) {
previewController.dismiss(animated: true)
parent.isShow = false
}
}
}
I referred to this to do this.
本文标签: swiftCannot show RPPreviewViewController with sheet modifier in SwiftUI WhyStack Overflow
版权声明:本文标题:swift - Cannot show RPPreviewViewController with .sheet modifier in SwiftUI. Why? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736306255a1932892.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论