[英]Dismiss presented sheet from other/root views in SwiftUI
I want to dismiss any presented sheet on receiving deeplink or notification.我想在接收深度链接或通知时关闭任何提交的表格。 This was possible in UIKit by checking rootview/navigation controller has presented modal and then easily you can dismiss it.
这在 UIKit 中是可能的,方法是检查 rootview/navigation controller 已呈现模式,然后您可以轻松地将其关闭。 How can I achieve the same behavior by using SwiftUI?
如何使用 SwiftUI 实现相同的行为?
One way is like this:一种方法是这样的:
.sheet(isPresented: $sheetConfig.isPresented) {
}
.onOpenURL { url in
sheetConfig.hide()
}
struct SheetConfig {
var isPresented = false
mutating func hide() {
isPresented = false
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.