Changing the UIBackButtonItem title

前端 未结 14 887
终归单人心
终归单人心 2020-12-04 17:48

I have a navigationController-based app. I want to change the title of the back button for the root view controller. I have tried the following code in the rootViewControlle

14条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 18:25

    Assumption: In your navigation controller have two ViewController is RootViewController and DetailViewController.

    • First Step: You must override back title of RootViewController

      self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"backTitle" style:UIBarButtonItemStylePlain target:nil action:nil];
      
    • Second Step:

      [self.navigationController pushViewController:detailVC animated:YES];

    That's done! You will see Back Button of DetailViewController is "backTitle"

提交回复
热议问题