简体   繁体   中英

Changing back button text in navigation bar after the child view is pushed in

I wanna change the back button text after the child view is already pushed in not before pushing it in.

More specifically, I'm developing an chatting app that shows unread messages count in the back button like this "<- Chats (3)". So I need to update the button text whenever the new message arrives.

After some digging it, I found that changing the title of the parent view eventually changes the back button text. But there is a redraw delay problem. It takes about 5 seconds until the back button is redrew after I changed the title.

In short, I'd like to know

  • How to redraw the back button immediately after I changed the parent's title.

  • or, better way to change the back button text after the button shows.

Any idea?

I don't know how you're doing this now, but putting this in a button method changed the back button title immediately:

-(IBAction)changeTitle:(id)sender {
     [self.navigationController.viewControllers[self.navigationController.viewControllers.count -2] setTitle:@"New"];
}

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