Cyclic view hierarchy

I am developing an app to memorize binary digits.

I have HomeView, MemoryView, RecallView and ResultView. I navigate between these using Navigationlink. But I use .navigationBarBackButtonHidden( “true” ) on all views because I don`t want the ability to go back to the previous screen before I come to ResultView. In the ResultView I want the ability to go back to the HomeView again. When I use Navigationlink to go back to HomeView from ResultView, there comes a new backbutton every time i cycle through the views, so for example after three cycles between the views, there is three backbuttons on homeview even when I have used .navigationBarBackButtonHidden( “true” ) on the homescreen to.

What is the best way to get this cycle of Views to work properly?

Hiding the navigation bar does not disable the intent nor the effect of a Navigation Link which is to transition to the View selected by the NavigationLink which automatically shows a < Back button to enable you to go back to the previous “View”.

When you use a NavigationLink, the View you are transitioning to is placed onto a ‘stack’ in memory. When you go back to the previous View by tapping the < Back button, the current View is popped off the stack and destroyed as part of memory management.

If you transition from View A to View B via a NavigationLink and then from View B to View C via another NavigationLink then View C to View D via another NavigationLink, then the expectation is that you will navigate back to View A by C and B which pops Views D, C and B off the stack. If you go back to View A via yet another NavigationLink from View D then you are going to see exactly the scenario you have already observed.

It would appear to me that your solution might be to make use of a tabbed Application where each of your Views is a separate Tab. That will enable you to select which ever view you want without having to Navigate through one to get to the other.

Hope that makes sense

Thank you very much! I ended up using a combination of TavView and NavigationView.