views:

578

answers:

1

Hi

I have a navigationController, I push a new viewController onto it's stack, I have been trying to figure out a way to switch this ViewController with another viewController from within the first ViewController.

I have 3 almost identical views, depending on the user interaction I would like to be able to switch between these views within the same stack index i.e. without pushing or popping views on the navigationController.

So if view C has index 3 on the navigationController stack and the user taps a certain button in view C the C1 view replaces C on the stack and gets index 3.

I have been through the UINavigation Class and can't find a way around this. If I popViewController from within the current viewController and the tries to pushViewController… well that can't be done as the viewController gets released when popping it. If I instead try to do pushViewController, well then I gets added on top of my current viewController.

I hope it makes sense and that someone can help me out:)

Thanks

+2  A: 

You can assign an NSArray of controllers to the viewControllers property to alter the entire stack instantaneously.

Neil Mix
Hi NeilThanks, I guess I could do that. Is there a way I can get an Array of the current stack -> change the last viewController and push it back on the NavigationController?
RickiG
Seems I didn't do my research well enough :/ the answer was here:http://stackoverflow.com/questions/410471/how-can-i-pop-a-view-from-a-uinavigationcontroller-and-replace-it-with-another-inThanks again Neil, you gave me the idea for searching for the answers:)
RickiG