I have an app that was developed in iOS 6. But now in iOS 7 or even my app compiled for iOS 6, but running on an iOS 7 device the top navigation bar (the new giant one in iOS 7) my content is hidden. The top navigation bar covers it. If I manually move it down with CGRect it looks good in iOS 7, but now iOS 6 looks horrible (to much space above it).
The app was built with autolayout off because autolayout is way to difficult to get things setup correctly.
My question is, is there an easy way to move the content down for iOS 7 only? I really don't want to have to turn autolayout back on and spend a month trying to get all the UI elements back in place. The app is pretty sophisticated with 30+ screens and a lot of animating view on screens.
Put self.edgesForExtendedLayout = UIRectEdgeNone;
in your ViewDidLoad method
You can also try setting the
navigationBar.translucent = NO
, as was mentioned in this answer.I think there's still a little bit of misconception going around this layout problem even if iOS 7 was rolled out more than a year ago. So I eventually decided to elaborate further my answer.
Here's the thing.
Because
automaticallyAdjustsScrollViewInsets
' default value isYES
, a pretty straightforward solution could be adding the following code:into the ViewController's
-viewDidLoad
method.If you wish to remove the status bar quirk (due to the bar translucency, so it's not weird whatsoever) add
self.navigationController.navigationBar.translucent = NO
. The default value isYES
. Note: this has nothing to do with the content, it's related to the content because of translucency but that's an altogether different story!Because
extendedLayoutIncludesOpaqueBars
isNO
by default,self.navigationController.navigationBar.translucent = NO
means basically havingOr, more generally, something like that (it's like pseudocode to give an idea...)
To hide the navigation bar, add the following to your UIViewController:
To show the navigation bar, use the following:
Below are the results on iOS7:
The screenshot on the left is with navigation bar hidden, while the image on the right is with navigation bar displayed - the contents of the table are correctly hidden under the navigation bar.
Hope this helps!