I have a stack of three VCs that are coordinated through a navigation controller and make use of a navigation bar. On this navigation bar, in each VC, I added the same button (a 'Logout' button) as a right bar button item:
UIBarButtonItem *logoutButton =
[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"LogoutButtonTitle", @"")
style:UIBarButtonItemStyleBordered
target:self
action:@selector(logout)];
[categoriesViewController.navigationItem setRightBarButtonItem:logoutButton];
[[self navigationController] pushViewController:categoriesViewController animated:YES];
So each view controller has this logout button in the navigation bar. When I push any of these controllers onto the navigation stack, the new view controllers loads as expected, everything is displayed and functions correctly, but right after the new view controller is displayed (after the animation finishes) the logout button shifts about 3px to the right.
I've tried adding the button before pushing the VC, in the init methods of the VC, in the viewDidLoad and viewDidAppear but still the same behavior. I can't seem to get rid of this shift.
What's strange is that the back button disappears and reappears when pushing the new VC (using the default animation) but the 'Logout' button seems to stay in place and just shift to the right after the animation finishes. Also, the font on the buttons is not the default font but one of the system fonts (Helvetica light), may be related to this.
Any ideas on why this is happening?