title: ViewDidLoad method in UIViewController - when does it get called?
body: <p>I have a <code>UIViewController</code> called LaunchController that is launched in my iPhone app when the app first opens:</p>
  
  <pre><code>@interface LaunchController : UIViewController&lt;UINavigationControllerDelegate, UIImagePickerControllerDelegate&gt;
  </code></pre>
  
  <p>Then, when a button is clicked, I push another view controller:</p>
  
  <pre><code> MainController *c = [[MainController alloc] initWithImage:image];
   [self presentModalViewController:c animated:NO];
  </code></pre>
  
  <p>MainController has the following constructor, which I use:</p>
  
  <pre><code>- (id)initWithImage:(UIImage *)img
  {
      self = [super init];
      if (self) {
          image = img;
          NSLog(@"inited the image");
      }
  
      return self;
  }
  </code></pre>
  
  <p>and then it has a viewDidLoad method as follows:</p>
  
  <pre><code>- (void)viewDidLoad
  {
      NSLog(@"calling view did load");
      [super viewDidLoad];
  
      UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
      [self.view addSubview:imageView];
      NSLog(@"displaying main controller");
  }
  </code></pre>
  
  <p>When the program runs, I see that the constructor for <code>MainController</code> is called (due to the output of <code>NSLog</code>), however <code>viewDidLoad</code> never gets called, even though I am calling <code>presentModalViewController</code>. Why is this? Why isn't <code>viewDidLoad</code> being called?</p>