title: Why is my UITabBar shifting down 20 pixels when loaded on portrait?
body: <p>I am loading a <code>UITabBarController</code> inside a <code>UINavigationController</code>. By default the <code>UITabBar</code> for the <code>UITabBarController</code> places it at the bottom of the view. By using the default option the bar is displayed correctly at the bottom position when the app is initiated on landscape.</p>
  
  <p><img src="https://i.stack.imgur.com/gcf4s.png" alt="enter image description here"></p>
  
  <p>This also makes portrait display correctly at the bottom, (but only when the app is initiated in landscape mode).
  <img src="https://i.stack.imgur.com/hnN6s.png" alt="enter image description here"></p>
  
  <p>If I start the app on portrait, it appears to shift downwards the height of the status bar on both landscape:
  <img src="https://i.stack.imgur.com/4KSpa.png" alt="enter image description here"></p>
  
  <p>and portrait:
  <img src="https://i.stack.imgur.com/anugl.png" alt="enter image description here"></p>
  
  <p>I am trying to have a similar effect as the CNBC app and display the <code>UITabBar</code> at the top of the view. After reviewing <a href="https://stackoverflow.com/questions/2568727/uitabbar-customization">Mihai Damian's question</a> I attempted to customize the UITabBar.</p>
  
  <p>I simply added a couple of lines of code:</p>
  
  <pre><code>-(void)loadView{
      UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
      contentView.backgroundColor = [UIColor clearColor];
      self.view = contentView;
      [contentView release];
  
      orderingTabBarController = [[UITabBarController alloc] init];
      OrderingSpecialsViewController *specialsViewController = [[OrderingSpecialsViewController alloc] initWithNibName:@"OrderingSpecialsViewController" bundle:nil];
      OrderingProductViewTabBarController *productViewTabBarController = [[OrderingProductViewTabBarController alloc] init];
      OrderingSummaryViewController *summaryViewController = [[OrderingSummaryViewController alloc] init];
  
      specialsViewController.title = @"SPECIALS";
      productViewTabBarController.title = @"PRODUCT";
      summaryViewController.title = @"ORDER SUMMARY";
  
      [orderingTabBarController setViewControllers:[NSArray arrayWithObjects:specialsViewController, productViewTabBarController, summaryViewController, nil] animated:YES];
      orderingTabBarController.tabBar.frame = CGRectMake(0.0, 110.0, self.view.frame.size.width, 40.0);
  
      [specialsViewController release];
      [productViewTabBarController release];
      [summaryViewController release];
  
      [self.view addSubview:orderingTabBarController.view];
  }
  </code></pre>
  
  <p>When I try modifying the frame of the UITabBar, it disappears on landscape mode:
  <img src="https://i.stack.imgur.com/lvf9P.png" alt="enter image description here"></p>
  
  <p>and appears at different height on portrait when it again initiated in landscape and portrait respectively.</p>
  
  <p>Initiated in landscape mode:
  <img src="https://i.stack.imgur.com/H4cMl.png" alt="enter image description here"></p>
  
  <p>Initiated in portrait mode:
  <img src="https://i.stack.imgur.com/fUnn8.png" alt="enter image description here"></p>
  
  <p>Has anyone encountered this problem before? If so, how did you go by solving it? Any help here would be greatly appreciated.</p>
  
  <p>It just seems to add the 20 pixels of the status bar when the view is loaded on portrait mode, as if it was not finding the status bar even though it is there, hence, it adds 20 pixels on top of the already existing 20 pixels for the status bar.</p>