Toolbar buttons flashing (quick fade out in) when pushing view controller animated
Asked Answered
G

3

6

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.

Gooey answered 23/3, 2013 at 15:3 Comment(1)
Found any Solutions ?Ul
L
1

I'm surprised that nobody answered you. I've just faced this issue, and here's a solution I've found.

  1. Subclass your navigation controller

  2. 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.

Longboat answered 26/5, 2014 at 4:5 Comment(1)
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
U
1

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.

Uretic answered 9/10, 2017 at 14:57 Comment(0)
C
0

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

Coralyn answered 15/9, 2019 at 5:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.