I have a stack of three VCs that are coordinated through the navigation controller and use the navigation bar. In this navigation bar in each VC, I added the same button ("Exit" button) as an element of the right button:
UIBarButtonItem *logoutButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"LogoutButtonTitle", @"") style:UIBarButtonItemStyleBordered target:self action:@selector(logout)]; [categoriesViewController.navigationItem setRightBarButtonItem:logoutButton]; [[self navigationController] pushViewController:categoriesViewController animated:YES];
Thus, each view controller has this exit button on the navigation bar. When I push any of these controllers onto the navigation stack, the new view controllers load, as expected, everything displays and functions correctly, but immediately after the new view controller is displayed (after the animation has finished), the logout button shifts by about 3 pixels correctly.
I tried adding a button before pressing VC, in the VC init methods, in viewDidLoad and viewDidAppear, but it will still be the same. I can not get rid of this shift.
It is strange that the "Back" button disappears and appears again when you press a new VC (using the default animation), but the "Exit" button seems to remain in place and simply shift to the right after the animation ends. In addition, the font on the buttons is not the default font, but may be associated with one of the system fonts (Helvetica light).
Any ideas on why this is happening?
ios uinavigationitem uinavigationcontroller uinavigationbar
Roger TheAlien
source share