Changing the UIBackButtonItem title

前端 未结 14 896
终归单人心
终归单人心 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:30

    I've had success by creating my own UIBarButtonItem instead of setting the title of the existing one:

    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
    self.navigationItem.backBarButtonItem = backButton;
    [backButton release];
    

提交回复
热议问题