简体   繁体   中英

Update back button in navigationbar

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"

尝试这个:

self.parentViewController.navigationItem.backBarButtonItem.title = @"foo";

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.

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM