xcode 不使用自动布局调整 iPhone 5 屏幕尺寸

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12753806/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 01:43:09  来源:igfitidea点击:

Adjust iPhone 5 Screen Size Without Using Autolayout

iphoneobjective-cxcodeios6iphone-5

提问by Vad

Enabling Autolayout in .xib or .storyboard and adding a splash screen of 640px by 1136px enables iPhone 5 resolution support for the taller screen.

在 .xib 或 .storyboard 中启用 Autolayout 并添加 640px x 1136px 的初始屏幕可以使 iPhone 5 分辨率支持更高的屏幕。

However, doing so, my app started to display some funny things where I assume autolayout is not a great idea.

然而,这样做,我的应用程序开始显示一些有趣的东西,我认为自动布局不是一个好主意。

I am wondering if there is a way to enable iPhone 5 device support, i.e. fix app's resolution without using Autolayout? Maybe I can set in the code?

我想知道是否有办法启用 iPhone 5 设备支持,即在不使用自动布局的情况下修复应用程序的分辨率?也许我可以在代码中设置?

If yes, then I will have no need to create 2 storyboards or nibs to support iOS5- and iOS6.

如果是,那么我将不需要创建 2 个故事板或笔尖来支持 iOS5- 和 iOS6。

回答by Dan Morrow

If you weren't using Autolayout before, you won't need to use it for iPhone 5 support.

如果您之前没有使用过 Autolayout,则不需要使用它来支持 iPhone 5。

When you're putting your interface together, you just need to check your bindings, and toggle between the taller phone size, and the regular phone size, as described here: Xcode Storyboard displaying the new iPhone 5 screen size?

当你把你的界面放在一起时,你只需要检查你的绑定,并在更高的手机尺寸和常规手机尺寸之间切换,如下所述: Xcode Storyboard 显示新的 iPhone 5 屏幕尺寸?

If your screens look fine in both screen sizes then you're done.

如果您的屏幕在两种屏幕尺寸下看起来都不错,那么您就大功告成了。

If you are doing a lot of coding to show your UI, then you'll have more work to do.

如果您要进行大量编码以显示您的 UI,那么您将有更多工作要做。

回答by Scott

I found a great answer a couple weeks ago (link below). You will copy and paste your older iPhone Storyboard, rename it to reflect the iPhone 5, and press the button that expands the screen size, found on the bottom of the layout grid. Some minor coding adjustments might be needed, but this sample code is used in the AppDelegate to detect which device is running, and hence, which Storyboard to use. You'll just have to duplicate your interfaces, but these GUI changes can be made without code and without AutoLayout (also good to note that AutoLayout removes iOS 5--and lower--compatibility)

几周前我找到了一个很好的答案(链接如下)。您将复制并粘贴旧的 iPhone Storyboard,将其重命名以反映 iPhone 5,然后按下位于布局网格底部的扩展屏幕尺寸的按钮。可能需要进行一些小的编码调整,但此示例代码在 AppDelegate 中用于检测正在运行的设备,从而检测要使用的 Storyboard。你只需要复制你的界面,但这些 GUI 更改可以在没有代码和 AutoLayout 的情况下进行(同样值得注意的是 AutoLayout 删除了 iOS 5-- 及更低版本的兼容性)

xcode 4.5 how to pick storyboards at launch

xcode 4.5 如何在发布时选择故事板