Search code examples
iphoneobjective-cuiviewcontrollerinterface-builderpushviewcontroller

viewDidLoad not being called when pushing UIViewController


I'm pushing a UIViewController like so:

UIViewController* individualsController = [[[UIViewController alloc] initWithNibName:@"IndividualsController" bundle:nil] autorelease];

[self.navigationController pushViewController:individualsController animated:YES];

The NIB itself is loading fine, all the elements load on the screen. BUT none of the view controller's methods are getting called. No viewDidLoad, no viewWillAppear, just a pushed NIB with nothing else.

The view outlet is set up in the NIB; I can't figure out why none of it is getting called!


Solution

  • One possibility is that you are instantiating it as a UIViewController rather than the name of your UIViewController subclass, so it is calling those methods, but on UIViewController, not on your class. Assuming that the subclass is called IndividualsController, try changing the line to

    IndividualsController* individualsController = [[[IndividualsController alloc] initWithNibName:@"IndividualsController" bundle:nil] autorelease];
    

    and see what happens.