3

我在 Xcode 5 中打开我当前的 xcode 4.6 版本项目。它在 IOS 7 中的 I Phone 和 I Pad 都可以正常工作。但是我想使用 Xcode 5 开发与 IOS 5 兼容的应用程序到 UP。但是当我将部署目标设置为5.0 并运行,显示更多自动布局错误。当我取消勾选时,它就起作用了。但在那种情况下,我们不能在 IOS 6 + 中使用自动布局运行应用程序。

以前当我使用 xcode 4.6 并将部署目标设置为 5 时,在编译时没有发现问题。仅在运行时发生异常。所以在那种情况下,我为 IOS 5 使用了没有自动布局的单独故事板。

但是在 xcode 5 中我不能使用该方法,因为在编译时会发生错误。那么我该如何解决这个问题?

4

1 回答 1

1

You cannot use auto layout on iOS 5. It's that simple. iOS 5 simply doesn't have the auto layout classes, so your app will get errors at run time when you launch it on an iOS 5 device.

You need to turn off auto layout in your xibs and storyboards, set the springs and struts, and write layoutSubviews or viewDidLayoutSubviews as necessary to lay out your views properly.

Since you will have to make your app work without auto layout, there's probably no point in also making your app use auto layout when it is available. Trying to use auto layout only on some devices will mean more code, more testing, and more confusion. Either change your deployment target to iOS 6.0 and just use auto layout, or use the old layout system on all versions of iOS.

于 2013-10-04T06:03:01.217 回答