UINavigation controller back title is ignores prev

2019-09-01 07:04发布

问题:

I would like my navigation controller to act the way that ios7 does = display the previous view title.

It doesn't always work for me

I have a SettingViewController :

- (void)viewDidLoad
{
    self.navigationItem.title = NSLocalizedStringFromTableInBundle(@"account_settings", nil,[GeneralUtil getLangBundle],nil);
    self.navigationController.navigationBar.translucent = NO;
    [super viewDidLoad];
}

When clicking on a button it opens the Profile Picture view controller like this:

UIViewController *vc = [[UIStoryboard profilePictureStoryBoard]instantiateInitialViewController];
            [self.navigationController pushViewController:vc animated:YES];

The profile picture is opened successfully but the title of the back button is Back and not the title of the Settings View controller which is Settings. What could be the problem?

回答1:

The back button changes its text in iOS 7 depending on the length of the title it needs to display.

If the name of the previous viewcontroller is too long to fit, it will instead just say 'Back'. If there's not even enough room for 'Back', it will just show the arrow.