28

this week came out iOS 7 Beta , and whenever an update comes out these always have to update the apps for compatibility consetar some bugs.

Well, I installed iOS 7 on my iPhone and apps principle worked perfectly, then installed Xcode 5 (preview) and compiled my projects, I realized that the new statusBar now is totally calm, your view controller will appear as her background.

This is where the problem arises, a white band of 20px at the bottom of the screen, due to the view controller have won the space that was once the statusBar.

If I fix this problem in my storyboards is all right, but then the problem in iOS 6 because of the 20px statusBar there are still there and the screen will be cut off.

I thought the simple solution was to check the version of iOS on startup and create a storyboard according to each one. In my project I have 3 storyboards, iPhone 3.5', 'iPhone 4' and 'iPad'. Soon have to create 3 more storyboards so because these 20 px.

That would be the best solution? I have some other alternative?

Sorry for the long text. Any help is welcome!

Sam Baumgarten
  • 2,231
  • 3
  • 21
  • 46
jucajl
  • 1,195
  • 3
  • 12
  • 29

1 Answers1

31

It's actually a fix for an old bug. The earlier versions of Xcode didn't handle the status bar correctly so people set the window's Y parameter to zero. The correct value would be 20, the vertical thickness of the status bar.

I vaguely recall that there is also a parameter in Interface Builder that would let you specify that the status bar was to be present, which would add 20 to the Y parameter. This didn't work correctly either.

Now that the bug has been fixed all the older windows will be 20 pixels higher than they should be (basically up under the status bar).

The consensus on the Apple dev forums is that Apple will add a way to specify iOS6 vs. iOS7 behavior in Interface Builder to fix this problem.

Cliff Harris
  • 754
  • 2
  • 7
  • 9
  • 1
    Is there any way the app looks fine for both iOS 6 and iOS 7. Need solution. Please help. –  Aug 12 '13 at 07:11
  • Ankit you can always check at runtime for the iOS version and then set the window's y parameter appropriately. – Ben Baron Aug 20 '13 at 11:54
  • 1
    I don't think this will be the right choice.. Need to figure out the standard solution, Not sure why Apple didn't take care about this.. :( – Srinivas G Sep 23 '13 at 12:05
  • 5
    Use this worked for me 100%. - (void) viewDidLayoutSubviews { CGRect viewBounds = self.view.bounds; CGFloat topBarOffset = self.topLayoutGuide.length; viewBounds.origin.y = -topBarOffset; self.view.bounds = viewBounds; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; } and add and set the "View controller-based status bar appearance" flag to no in plist. – YSR fan Sep 24 '13 at 11:07
  • i found this way like this http://stackoverflow.com/questions/18294872/ios-7-status-bar-back-to-ios-6-style/18966372#18966372 – İbrahim Özbölük Sep 25 '13 at 17:17
  • For iPhoneX the height is 44 and not 20 – Musa almatri Sep 13 '17 at 15:57