Ios 打开第二个视图,如NavigationLink onRecive()

Ios 打开第二个视图,如NavigationLink onRecive(),ios,view,swiftui,swiftui-navigationlink,Ios,View,Swiftui,Swiftui Navigationlink,您好,我尝试通过接收通知以相同的NavigationLink模式打开一个新视图 var body: some View { return VStack { WebView(webPageURL:webPageURL).onReceive(NotificationCenter.default.publisher(for: .viewNotificationMessage)) { notification in let message = notif

您好,我尝试通过接收通知以相同的NavigationLink模式打开一个新视图

var body: some View {
    return VStack {
        WebView(webPageURL:webPageURL).onReceive(NotificationCenter.default.publisher(for: .viewNotificationMessage)) { notification in

            let message = notification.object as? String ?? ""
            if(message == "Show"){
                //Open her SecoundView like NavigationLink
            }
        }
        NavigationLink(destination: SecoundView()) {
            Text("Do Something")
        }
    }
}
这是:

@State private var isActive = false
var body: some View {
    return VStack {
        WebView(webPageURL:webPageURL).onReceive(NotificationCenter.default.publisher(for: .viewNotificationMessage)) { notification in

            let message = notification.object as? String ?? ""
            if(message == "Show"){
                self.isActive = true // activate the link below
            }
        }.background(
           NavigationLink(destination: SecoundView(), isActive: $isActive) {
            EmptyView()
        })
    }
}

这个解决方案目前看来不错。但是我想从视图中删除NavigationLink。但这种解决方案不可能做到这一点。我尝试启动视图“SecoundView”,使其行为类似于导航链接。@TheBuro。你所说的像NavigationLink是什么意思?若您只想为用户删除它,但有相同的行为,那个么请参阅更新。好的,更新的代码部分看起来更好。我指的是从侧面打开新视图的行为。上面有一支箭。