How to make .xib files compatible to both iOS7, iOS6 and earlier [duplicate]

帅比萌擦擦* 提交于 2019-12-14 04:00:45

问题


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 main view and uncheck "Use Autolayout"
  • Select every subView (UIButton, UILabel etc), go to the frame setting section
    1. Increase their Y frame values by 20
      • but it seems you, @SudhakarTharigoppula, don't need to do this step.
        ...just do the next step
    2. Enter a value of -20 for ΔY

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!