title: Presenting a UIViewController from inside another UIViewController?
body: <p>I'm pretty new to iOS, and am attempting to present a view controller from within another view controller as described here:</p>
  
  <p><a href="http://www.iphonedevsdk.com/forum/iphone-sdk-development/98797-switching-uiviewcontrollers-programmatically.html" rel="nofollow">Stack overflow answer</a> (see third answer)</p>
  
  <p>and also <a href="https://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007457-CH1-SW1" rel="nofollow">here on Apple's site</a></p>
  
  <p>I start with the <a href="https://developer.apple.com/library/ios/#samplecode/HelloWorld_iPhone/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007709" rel="nofollow">Hello World Example code</a>. I open up MyViewController.m and modify the updateString() method, adding this code to the end:</p>
  
  <pre><code>{
          // Get the application's "window"
      UIWindow *window = [UIApplication sharedApplication].keyWindow;
          // Get the window's rootViewController (NOTE: Only works on iOS 4.0 or later!)
      UIViewController *rootViewController = window.rootViewController;
  
          // Create our new controller
      UIViewController *enterNameController = [[UIViewController alloc] initWithNibName:@"HighScore" bundle:[NSBundle mainBundle]];
  
      if (enterNameController != NULL)
      {
          printf("\nLoaded UIView controller. Installing as actionSheetController...\n\n");
  
          UINavigationController *navigationController = [[UINavigationController alloc]
                           initWithRootViewController:enterNameController];
  
              // Present out Enter Name for High Score view as a modal view
      //  [rootViewController presentViewController:navigationController animated:YES];       // iOS 2.0 and newer
          [self presentViewController:navigationController animated:YES completion: nil];     // iOS 5.0 and newer
      }
  }
  </code></pre>
  
  <p>I have also created a NIB file called "HighScore.xib" that I put with the other NIB files that came with the HelloWorld, and I also added HighScore.xib to the XCode project, and dragged it into the "Copy Bundle Resources" section.</p>
  
  <p>As-is, I get an error when running and entering text into the edit field:</p>
  
  <p><em>*</em> Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle  (loaded)' with name 'HighScore''</p>
  
  <p>However if I change the final statement to use "rootViewController" instead of "self" then <em>nothing</em> happens. No exception, but no new view is presented either.</p>
  
  <p>Questions:</p>
  
  <p>1) Why won't my NIB load? I'm obviously doing something wrong here.</p>
  
  <p>2) Why does using "rootViewController" instead of "self" produce different results? Shouldn't the rootViewController find the same class as "self"?</p>
  
  <p>Note that when using "rootViewController" I get a warning in XCode: "MyViewController' may not respond to '-presentViewController:animated:completion"</p>