问题
I am using .xib files in my app and I am using xcode5.
If I run my app in iOS6 and earlier, the alignments are missing.
Any one know about this issue?
Do we have to create separate .xib files for iOS7 and iOS6?
EDIT: I turned off Autolayout but under iOS6, the views are still going down by 20 pixels.
回答1:
in iOS7, the app windows starts from y=0px (in iOS6-, it begins at y=20px).
The quickest and easiest way to handle this, (and since you're already using Xcode5), is to switch off Autolayout and utilize the iOS6/7 Delta values for every view.
Basically:
- Select every
viewController
's mainview
and uncheck "Use Autolayout
" - Select every
subView
(UIButton
,UILabel
etc), go to the frame setting section- Increase their Y frame values by 20
- but it seems you, @SudhakarTharigoppula, don't need to do this step.
...just do the next step
- but it seems you, @SudhakarTharigoppula, don't need to do this step.
- Enter a value of -20 for ΔY
- Increase their Y frame values by 20
This will start your app by leaving 20px in iOS7 but back in iOS6, the ΔY of -20px will compensate for the extra 20px you had given to every subView
.
see: Status bar and navigation bar issue in IOS7
回答2:
If you haven't done so already, turn off AutoLayout in your xib files. Autolayout only came in with iOS 6 and newer iOS versions.
Also, you can preview what XIB files look like between iOS 6 and iOS 7 via a popup menu in the File Inspector:

来源:https://stackoverflow.com/questions/20776131/how-to-make-xib-files-compatible-to-both-ios7-ios6-and-earlier