title: UIViewController being pushed down on screen when displayed using insertSubview
body: <p>Having a bit of a problem, here's the breakdown:</p>
  
  <p>My AppDelegate uses as it's rootViewController a view controller. This view controller's purpose is to swap a couple of other view controllers in and out, call it login and main screens. For the sake of simplicity I've removed any swapping code from the code that I will post and am having the rootViewController simply show it's first content view controller, say login.</p>
  
  <p>The issue I'm having is that the content view controller seems to be pushed down a little bit inside the rootViewController. I've given the rootViewController a blue background and the content view controller an orange background. Here's my code:</p>
  
  <p>AppDelegate.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @class MainViewController;
  
  @interface AppDelegate : UIResponder &lt;UIApplicationDelegate&gt;
  
  @property (strong, nonatomic) UIWindow *window;
  @property (strong, nonatomic) MainViewController *main;
  
  @end
  </code></pre>
  
  <p>AppDelegate.m</p>
  
  <pre><code>#import "AppDelegate.h"
  #import "MainViewController.h"
  
  @implementation AppDelegate
  
  @synthesize main;
  
  - (void)dealloc
  {
      [_window release];
      [main release];
      [super dealloc];
  }
  
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  {
      self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
  
      MainViewController *mainVC = [[MainViewController alloc] init];
      self.main = mainVC;
      self.window.rootViewController = self.main;
  
      [self.window makeKeyAndVisible];
  
      return YES;
  }
  </code></pre>
  
  <p>MainViewController.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @class ContentViewController;
  
  @interface MainViewController : UIViewController
  
  @property (nonatomic, retain) ContentViewController *content;
  
  @end
  </code></pre>
  
  <p>MainViewController.m</p>
  
  <pre><code>#import "MainViewController.h"
  #import "ContentViewController.h"
  
  @implementation MainViewController
  
  @synthesize content;
  
  - (id)init
  {
  self = [super init];
      if (self ) {
          // Custom initialization
      }
      return self;
  }
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
  
      self.view.backgroundColor = [UIColor blueColor];
  
      ContentViewController *viewController = [[ContentViewController alloc] init];
      self.content = viewController;
      [self.view insertSubview:self.content.view atIndex:0];              
  }
  
  - (void)dealloc {
      [content release];  
      [super dealloc];
  }
  
  @end
  </code></pre>
  
  <p>ContentViewController.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface LoginVC : UIViewController
  
  @end
  </code></pre>
  
  <p>ContentViewController.m</p>
  
  <pre><code>#import "ContentViewController.h"
  
  @implementation ContentViewController
  
  - (id)init
  {
      self = [super init];
      if (self) {
          // Custom initialization
      }
      return self;
  }
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      // Do any additional setup after loading the view.
  
      self.view.backgroundColor = [UIColor orangeColor];
  }
  
  - (void)dealloc {
      [super dealloc];
  }
  
  @end
  </code></pre>
  
  <p>The above codes gives me a status bar with a blue strip (approximately the height of the status bar) under it (which is the main view controller) followed by the orange content view controller taking up the rest of the screen. For some reason that main view controller seems to be pushing the content view controller down a little.</p>
  
  <p>Strangely, if I create a view controller and use a XIB for drawing the view, it looks just fine and the content view it right up against the top of the main view.</p>
  
  <p>If anybody could shed some light on this issue I'd very much appreciate it.</p>
  
  <p>Cheers</p>