0

my app shows a white bar on the top for the 4 inch screen (= iPhone 5). For iPhone 4, it works nicely (no white bar is shown). What is the problem (iOS SDK 6.1)?

This is, how I add the UINavigationController:

self.navigationController = [[UINavigationController alloc] initWithRootViewController:exploreViewController];

self.navigationController.navigationBar.tintColor = [UIColor greenColor];
self.navigationController.navigationItem.hidesBackButton = YES;

[self.view addSubview:self.navigationController.view];

Best, Stefanenter image description here

enter image description here

Stefan
  • 28,843
  • 15
  • 64
  • 76
  • 1
    are you using a nib or a storyboard? – Polyov Jul 22 '13 at 16:55
  • I am using a nib and add an UINavigationController programatically. I use the UINavigationController to display different center views (pink colored) and a UINavigationBar (green colored). – Stefan Jul 22 '13 at 16:59
  • 1
    make sure that you're setting up the nib to be friendly to both sizes of devices. see: http://stackoverflow.com/questions/13275144/how-to-make-xib-compatible-with-both-iphone-5-and-iphone-4-devices – Polyov Jul 22 '13 at 17:01
  • Thanks, but it is already set for the 4 inch screen ;-) I've attached a screenshot of the Interface Builder settings. – Stefan Jul 22 '13 at 17:10
  • 1
    can you post how you are adding the navigation controller? also when using the Interface Builder and adding nav controllers programmatically it's a good idea to set the Top Bar to "Navigation Bar", so whatever you add in IB won't be covered by the nav bar. – Polyov Jul 22 '13 at 17:14

1 Answers1

2

Change

[self.view addSubview:self.navigationController.view];

to

[self.window setRootViewController:self.navigationController];

You should be adding the Navigation Controller in your AppDelegate. Here's a good tutorial.

Polyov
  • 2,281
  • 2
  • 26
  • 36