且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使.xib文件与iOS7,iOS6和更早版本兼容

更新时间:2023-12-04 15:55:40

在iOS7中,应用程序窗口从y = 0px开始(在iOS6-中,从y = 20px开始)。

in iOS7, the app windows starts from y=0px (in iOS6-, it begins at y=20px).

处理此问题的最快,最简单的方法(,因为您已经在使用Xcode5 ),是关闭自动版式并利用每个视图的 iOS6 / 7 Delta 值。

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.

基本上:


  • 选择每个 viewController 的主视图,然后取消选中 使用自动版式

  • 选择每个 subView UIButton UILabel 等) ,请转到框架设置部分

  • Select every viewController's main view and uncheck "Use Autolayout"
  • Select every subView (UIButton, UILabel etc), go to the frame setting section

  1. 将其Y框架值增加20


    • 但似乎,@ SudhakarTharigoppula,不需要执行此步骤。

      ...只需执行下一步

  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

输入值-20

这将通过在iOS7中保留20px来启动您的应用,但在iOS6中,-20px的ΔY将补偿您为每个 subView 额外分配了20px。

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.

请参阅: IOS7中的状态栏和导航栏问题