tags:

views:

40

answers:

3

if i change the title of the parentViewController, how do i update the back button displayed in the upper left corner of the child view. ?

i already know to set self.title when i am actually displaying the parent view, but i would like to know how to refresh the button with the new title displayed in the child view while i am looking at the child view. i have tried

self.parentViewController.title = @"foo"

and

self.parentViewController.navigationItem.title = @"foo"
+3  A: 

Try this:

self.parentViewController.navigationItem.backBarButtonItem.title = @"foo";
Jacob Relkin
That did not work... seemed hopeful though
griotspeak
to clarify, i think all of the listed methods, including yours, 'set' the barItem...but i can't get it to update without popping the parent view
griotspeak
Delegation, at first thought, seemed like overkill, but it worked perfectly. I couldn't get this working, but if you post one that does or just change your answer to 'use a delegate' i will mark this as correct. someone should get something, i figure.
griotspeak
A: 

You need to set the title for the navigationItem that belongs to the 'previous' controller. So in a navigationController that would be the one 'to the left'.

You can set this title first and then push the new view onto the stack.

Rengers
That is what jacob does, sans pushing a new view onto the stack. I suppose I am not being clear. While i am in the child view, i want to update the back button. Is the only way to do this by making a new button and replacing the old back button?
griotspeak
With child view you mean a subview of the view that is currently on top of the navigation stack? If that's the case, I think Jacobs way should work. Strange...
Rengers
A: 

What I ended up doing was implementing a delegate protocol. my child view tells the parent the new name and the parent sets its title. with self.title = @"foo"

griotspeak