2

I have a 'Back' UIBarButtonItem as you can see in the 4th ViewController

The Back button is connected to an IBAction:

- (IBAction)backClicked:(UIBarButtonItem *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

But when I call popViewControllerAnimated: from the fourth ViewController to go back to the 3rd ViewController, it changes the original color of the Tab Bar Tab's UINavigationBar tintColor. The original navbar tintColor of the UITabBarController is set to green by the AppDelegate and the pop changes it to dark grey(the color of the 4th VC's navbar)

How do I not lose my navbar tintcolor when calling popViewControllerAnimated:?? Please help, I've been trying to figure this out for days.

Chisx
  • 1,886
  • 4
  • 22
  • 48

2 Answers2

2

Check that you're not setting it in the viewWillAppear of the previous view.

Neva
  • 1,340
  • 9
  • 11
  • No the UITabBar Appearance is set in the AppDelegate.m file with this code: `[[UITabBar appearance] setTintColor:[UIColor colorWithHexString:@"#669900"]];` should I be reseting the UITabBar color in the viewWillAppear of the first tab bar tab view? – Chisx Jun 17 '14 at 04:34
  • ...Nvm I just tried that.. seems that I can't set it in the viewWillAppear or the viewDidLoad. – Chisx Jun 17 '14 at 04:40
0

Replace

[self.navigationController popViewControllerAnimated:YES];

with the following (this is the swift code)

self.dismissViewControllerAnimated(true, completion: nil)

You didn't use a navigation controller when you were adding the fourth view controller. That's why simply call dismissViewControllerAnimated method.

You have to use UINavigationController and its pop methods only when you add your view controllers via pushViewController method.

I learned this via - Go back to previous view controller doesn't work

Community
  • 1
  • 1
Bilbo Baggins
  • 3,494
  • 6
  • 36
  • 60