1

I am trying to setTintColor for a viewcontroller that inherits from a UITableViewController.

I tried to put

[self.navigationController.navigationBar setTintColor:[UIColor blackColor]];

as the last line in loadView, but the color doesn't change. Where should I make this change?

Here is the interface definition of the controller:

@interface MyViewController : UITableViewController 
{
    Model *model;

    NSArray * calculators;
}
@end

UPDATE: I finally put it in viewDidAppear and it worked.

5
  • 1
    Try placing it in viewDidLoad instead.
    – BoltClock
    Dec 30, 2010 at 17:28
  • @BoltClock. Tried, didn't work.
    – John Smith
    Dec 30, 2010 at 17:41
  • Since you are settings black as the tint color, you might want to change the bar style instead, i.e. self.navigationController.navigationBar.barStyle = UIBarStyleBlack;. I would put this in viewDidLoad.
    – mrueg
    Dec 30, 2010 at 17:45
  • Is your table view controller actually in a navigation controller, or do you create a navigation bar separately?
    – BoltClock
    Dec 30, 2010 at 17:59
  • @BoltClock: Check my definition of UIViewController.
    – John Smith
    Dec 30, 2010 at 18:05

4 Answers 4

0

Are you sure that your self.navigationController is not nil? This is a usual bug happenning all the time that you didn't present your MyViewController with a navigationController

0

Try this

self.navigationController.navigationBar.tintColor = [UIColor blackColor];
2
  • 1
    What's the difference between that and using setTintColor:?
    – BoltClock
    Dec 30, 2010 at 18:36
  • Yeah, it's exactly the same thing.
    – Tom Irving
    Dec 30, 2010 at 20:27
0

I put my solution in the question.

0
-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar setTintColor:[UIColor blackColor]];
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.