It's not really "popping" views off of the stack, but your SceneDelegate
can set the rootViewController
to any View you want (see line 28 of default SceneDelegate.swift
). In your case you want it to be ContentView
again.
For example in your SceneDelegate
add something like:
func toContentView() {
let contentView = ContentView()
window?.rootViewController = UIHostingController(rootView: contentView)
}
Then in DView
, change the NavigationLink
to a Button
that just does:
(UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate)?.toContentView()
If you have multiple scenes, you'll need a bit more.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…