When pushing a view controller my toolbar buttons fade out and then in again with the new view. The problem is that i have the same buttons in the next view as the previous so it looks like the buttons do a quick flash when switching screen. My question is if this can be avoided by disable the fade out of toolbar buttons for the navigation controller when pushing to a new view or if the toolbar can be bound to the navigation controller in such a way that it is the same for all views. The last suggestion since i have seen that my navigation bar buttons does not fade out when pushing a new screen.
Toolbar buttons flashing (quick fade out in) when pushing view controller animated
Asked Answered
I'm surprised that nobody answered you. I've just faced this issue, and here's a solution I've found.
Subclass your navigation controller
Override you push/pop methods
-(UIViewController*)popViewControllerAnimated:(BOOL)animated { self.navigationBarHidden = YES; UIViewController *vc = [super popViewControllerAnimated:animated]; self.navigationBarHidden = NO; return vc; } -(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated { self.navigationBarHidden = YES; [self pushViewController:viewController animated:animated]; self.navigationBarHidden = NO; }
It did the trick for me.
This almost works for me, but unfortunately, it causes the table view in my controller to scroll by the height of the navigation bar at the beginning of the transition. –
Anywhere
I know this question is old, but there is a simple solution: Set both controller's navigation items to the same bar button item, and it won't animate. Eg:
UIBarButtonItem* item = [[UIBarButtonItem alloc] initWith...];
viewController1.rightBarButtonItem = item;
viewController2.rightBarButtonItem = item;
If you now push viewController2 after showing viewController1, the navigation item will not animate.
For building up a toolbar in the code, I think it should be in the ViewWillAppear lifecycle method. I had previously built up a toolbar in code but in ViewDidLoad, and I saw this quick fade in/fade out
© 2022 - 2024 — McMap. All rights reserved.