Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If I understand correctly, you're using <code>NavigationController.PopToViewController(controller);</code> to navigate back to a certain view controller but keep a reference of the View Controllers that are popped from the navigation stack.</p> <p>What I think is happening is because you're keeping a reference to these View Controllers, they're still in memory and thus the <code>IsViewLoaded</code> property is still <code>true</code> despite the View Controller not actually existing on the navigation stack. </p> <p>Rather than using the <code>IsViewLoaded</code> property, you should check whether the View Controller exists in the <code>NavigationController.ViewControllers</code> array, if it does then Pop to it, if it doesn't then push it.</p> <p>E.g.</p> <pre><code>if (BaseView.NavigationController.ViewControllers.Contains(CurrentViewController)) { BaseView.NavigationController.PopToViewController(CurrentViewController,false); } else { BaseView.NavigationController.PushViewController(CurrentViewController,true); } </code></pre> <p><strong>Edit</strong></p> <p>So you mention you'd like a view to persist on the navigation stack. Well, using PopToViewController will remove <strong>ALL</strong> View Controllers between the TopViewController and the specified Controller.</p> <p>In order to achieve what you're wanting, you could directly manipulate the <code>NavigationControllers.ViewControllers</code> array. Only problem with this is you'll lose the nice animations that the Push/Pop methods provide. </p> <pre><code>// Changes order of View Controllers currently in the stack. You can also add/remove // controllers using this method. NavigationController.ViewControllers = new UIViewController[]{ NavigationController.ViewControllers[1], NavigationController.ViewControllers[0], NavigationController.ViewControllers[3], NavigationController.ViewControllers[2]}; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload