title: Present and dismiss modal view controller
body: <p>Can anyone give me the example code that I can use to first present a modal view controller, then dismiss it? This is what I have been trying:</p>
  
  <pre><code>NSLog(@"%@", blue.modalViewController);
  [blue presentModalViewController:red animated:YES];
  NSLog(@"%@", blue.modalViewController);
  [blue dismissModalViewControllerAnimated:YES];
  NSLog(@"%@", blue.modalViewController);
  </code></pre>
  
  <p>This code is in viewDidLoad ("blue" and "red" are both subclasses of UIViewController). I expect that I will show the red view and then immediately hide it, with some animation. However this piece of code only presents the modal view and does not dismiss it. Any idea? The first log shows "null" while the two other logs show <code>&lt;RedViewController: 0x3d21bf0&gt;</code></p>
  
  <p>Another point is, if I put this code in applicationDidFinishLaunching: the red view does not appear at all, and all logs get "null"</p>