0

Hoping somebody can shed some light on this issue...

I'm working on an app that has multiple UIViewControllers each with UITableViews and UIViews in them. I wish to change the background colour for one of the UIViews programmatically. Easy enough to do. I use the RGB values for the colour from a global constants file so that every screen uses the same colour and it can be changed easily for every screen. The issue is that I presently have the code to change the background colour of the view in the viewDidLoad method and I physically see the view change colour. So it loads with whatever it's set to in interface builder and then switches to what I'm setting it to.

Obviously I just want it to appear already set to the colour I'm trying to set it to.

Any thoughts?

More Info

The UIViewController is loaded as a subview into another UIViewController. This parent UIViewController manages a few other UIViewController and allows the user to switch between them. This is how the child UIViewController is loaded:

SomeViewController *vc = [[SomeViewController alloc] initWithNibName:@"SomeViewController" bundle:nil];
self.someViewControllerOutlet = vc;
osvc = nil, [osvc release];
[self.view insertSubview:self.someViewControllerOutlet.view atIndex:0];

Hope this clarifies things.

r0ddy
  • 159
  • 2
  • 10
  • 1
    `viewDidLoad` is the correct place to set view properties because it is called before the view is presented (and before `viewWillAppear`). The fact that it's not working for you points to some other problem. We probably need to know more about what you are doing. – Robin Summerhill Nov 12 '12 at 16:33
  • Still a little unfamiliar with the site but I made an edit, see above. Thanks, btw. – r0ddy Nov 12 '12 at 16:47

1 Answers1

0

try using

       -(void)awakeFromXib
       {
          // do your code here
       }
Jasmeet Singh
  • 564
  • 3
  • 9