Search code examples
iosuiviewcontrolleruinavigationcontrolleruistoryboardsegue

Using a UINavigationController for a set path without Back options


I am using a UINavigationController within my app (as expected) for a specific path the user takes when taking a turn in my turn based game.

When they move through the turn controllers they do not actually have the option to go Back from the Navigation Controller. This is planned/expected behaviour.

My question is, is it best to keep the other controllers on the UINavigationController stack when they are not going to be used again.

Should they be de-alloced immediately, or wait for the whole turn to be complete and let them go when the navigation controller goes (how it is at the moment). Some of the controllers hold data/images etc as properties so I am wondering if it would be more efficient to get rid of these on the fly?

If it is, what is the best method to load new controllers into the UINavigationController at present I am using self performSegue... or buttons that push to the VC from the storyboard setup.


Solution

  • You can manipulate navigation controller viewControllers using this code

       NSMutableArray *viewControllers = self.navController.viewControllers;
        //remove or add in the array
    
        [self.navController setViewControllers:viewControllers];