views:

159

answers:

1

I have a navigation controller that displays viewcontroller A. There is a right button (labelled "B") that leads to viewcontroller B.

Now, when the user makes an important change in (the view managed by) viewcontroller B, viewcontroller B's usefulness has ended.

From then on, VC A should lead to a new VC, viewcontroller C. This is the behavior that I want. However, because viewcontroller A has already been created with a right button leading to "B", I'm not sure how to get it to re-configure itself. I want it to now have a right button labeled "C" which leads to viewcontroller C.

I have been unable to find any sample code that addresses a situation like this. To boil the problem down to its essence, I just need to be able to re-make viewcontroller A while it's in the navcontroller's stack.

A: 

You can store a reference to controller A in your application delegate and, when controller B is finished, change controller A's navigation item like appdelegate.controllerA.navigationItem.rightBarButtonItem = /* a new bar button item to create and push controller C goes here ... */.

MrMage
Yes, but that won't make the current nav bar redraw itself with a new button.
mwt
Of course it will, as long as you are using a `UINavigationController` to manage your view controller stack (which you really should).
MrMage
All right MrMage, I had a chance to try that out. It worked perfectly. Combined with another technique (popping a view controller to get rid of it), it's solved my issue. Many thanks!
mwt