title: How do you reload UIViewController's view from a XIB after a memory warning blows it away?
body: <p>I have an iPhone view controller that's initialized with a XIB.</p>
  
  <p>If a view controller's view is not visible when a memory warning comes through, it sets its view to nil (releasing it).  But when an overlapping view is dismissed and the cleared-out view becomes visible again, Cocoa doesn't reload it from the XIB; it simply creates a blank one.  This leaves a blank white screen, and a broken app.</p>
  
  <p>The Apple doc for UIViewController's <strong>loadView</strong> method says, "If the view controller has an associated nib file, this method loads the view from the nib file. A view controller has an associated nib file if the nibName property returns a non-nil value."  So I overrode <strong>loadView</strong> simply to check <strong>nibName</strong> after initializing the controller, and <strong>nibName</strong> is correct.  So subsequent calls to <strong>loadView</strong> should be reloading from the XIB.  I verified that <strong>loadView</strong> is called again after the memory warning.</p>
  
  <p><strong>UPDATE</strong>: With more testing and logging, I've determined that after the second <strong>viewDidLoad</strong> call, the view's IBOutlets are non-nil.  Since I set them to nil in <strong>viewDidUnload</strong>, I conclude that the view was indeed reloaded from the XIB.  So why is it showing up as an all-white screen?</p>
  
  <p>Thanks for any insight.</p>
  
  <p>Here's <strong>viewDidLoad</strong>:</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
  
      _photoViewController = [[EGOSimplePhotoViewController alloc] initWithPhotoSource:_photoSource
                                                                        scrollView:bigImageScrollView
                                                                       enclosingView:photoSquare];
      _photoViewController.delegate = self;
  
      if(_progressHUD == nil)
      {
          if(self.navigationController.view != nil)
          {
              _progressHUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
          }
          else
          {
              _progressHUD = [[MBProgressHUD alloc] initWithView:self.view];
          }
      }
  
      // Add HUD to screen.
      if(self.navigationController.view != nil)
      {
          [self.navigationController.view addSubview:_progressHUD];
      }
      else
      {
          [self.view addSubview:_progressHUD];
      }
  
      [_progressHUD release];
  
      _progressHUD.labelText = @"Loading...";
      [_progressHUD show:YES];
  }
  </code></pre>
  
  <p>And <strong>viewDidUnload</strong>:</p>
  
  <pre><code>- (void)viewDidUnload
  {
      [_photoViewController release];
      [super viewDidUnload];
  }
  </code></pre>