This question already has an answer here:
I tried to test my app in iOS 7, and then I find my view appears over the status bar... As I read, in iOS 7, the status bar is hidden. So how do I make it compatible to run both in iOS 6 and iOS 7? Should I have to make different .xib files for different iOS versions for each screen?
I have been going through reading this: If both versions of a standard app should have a similar layout, use Auto Layout to create a UI that works correctly in both versions of iOS. To support multiple versions of iOS, specify a single set of constraints that Auto Layout can use to adjust the views and controls in the storyboard or XIB files (to learn more about constraints, see “Constraints Express Relationships Between Views”).
If both versions of a standard app should have a similar layout, and you’re not using Auto Layout, use offsets. To use offsets, first update the UI for iOS 7. Next, specify values that define the origin, height, and width of each element in the earlier UI as offsets from the element’s new position in the iOS 7 UI.
But when I use autolayout in .xib, it shows an error that autolayout is in a prior version to iOS 6.
How do I fix this problem?
You just once need to check your main UIView size for iOS 7.0 & later & iOS 6.0 & lower, probably you will get idea.
From iOS 7 Apple has changed main view size = fixed It means if you add navigation bar, tabbar your view size remains same [iPhone 4s : 320 *480, iPhone 5 : 320 * 568].
You probably need to add the following code on each view controller.
iOS 7 apparently supports the Status Bar being hidden for some views but not others. To hide it for all views, do the following:
Hide during application launch
is still checked, to support previous OS versions.View controller-based status bar appearance
and set it toNO
.I have the same issue. For now I made two hacks and will decide with which I'll go:
UIStatusBarHidden
andUIViewControllerBasedStatusBarAppearance
to true.How do I make Autolayout account for the status bar area?
Well, I figured it out.
In your sub-view (
BRSMyListSubViewController
in my case), inviewDidLoad
, you need to set one of these twoOR
Interestingly enough, in the root view controller, these values are set to default
UIRectEdgeAll
,NO
andYES
respectively, but itstableView
is NOT under navbar and footer.I don't know why it's so illogical.
It's also strange that
edgesForExtendedLayout
has to be mixed with one of two other properties even though it's clearly responsible for the behavior.If you like to show a status bar under iOS 7 with Xcode 5, just rearrange the buttons and other subviews to make enough space around the status bar. But, just wait! I like to support iOS 6 too. How do I do that?
I found documentation from Apple, and found the "Supporting Two Versions of a Standard App" title in the document.
If you are editing an XIB file, select it and click assistant editor. You will able to find the "manual, automatic..." menu around there. Then choose "preview".
Then you'll find a view layout side by side. Then you will notice that there is a popup button around the right bottom of the right pane (view); it says "iOS 7 and later". You can choose "iOS 6.1 and earlier". Woa! Now you can make adjustments for iOS 6.1 without affecting the layout of iOS 7.
If you are working on the storyboard, it is basically the same. You choose a view controller object, and click assistant editor mode, choose "preview", then "iOS7 and later"... Bluh Bluh Bluh.
I'm not sure, but only the assistant editor is capable of switching to iOS 7+/iOS 6- mode. I just found this very recently, so please point out, if there are any misunderstandings or other tricks.
There is no need to build multi-xib. I think your problem is the "20px": the same XIB file looks great in iOS 6, but it misses 20 pixels in iOS 7.
For example, you have a view, and it's Y = 0. In iOS 6, it's next to the bottom of the status bar. In iOS 7, it appears over the status bar.
You should use Xcode 5 to open your XIB files and enable assistant editor. Follow these steps:
Select file inspector, and switch "View As" to "iOS 7 and later"
Select size inspector, and fill deltaY with "-20"
It's done!