0

Hello I am new to SwiftUI,

I have two navigationStack one is in parent and one is in childview, now i have to use parent navigationStack from child but if i is use navigationlink in child view it refers to child's navigation view,

For example RootView1, RootView2

RootView1 has navigationStack and it navigate to ChildView. ChildView has navigationStack for its sub views now i want to navigate to RootView2 from ChildView

If i use navigationLink in ChildView it refers to ChildView's navigationview instead i want to call parent's navigation view

How can i achieve this?

Multiple NavigationView/NavigationStack hierarchy in SwiftUI

4
  • 1
    Most apps only need 1 NavigationView. There are a few exceptions but this doesn’t sound like one of them. Commented Mar 20, 2024 at 9:26
  • @loremipsum, yes i agree with you but in my case I have first parent view->chileview (with navigation stack) ->subchildview Now i want to open second parent view from sub child view and for that i want to access first parent view's navigation stack Commented Mar 21, 2024 at 13:10
  • You only need 1 NavigationView/Stack. TabView/sheet’s are exceptions Commented Mar 21, 2024 at 13:21
  • so what about model presentation to another view than requires navigation such as .fullScreenCover? wouldn't that need another NavigationStack? Commented Jun 23, 2024 at 2:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.