我该如何定位的观点在Interface Builder为3.5“和4个”视网膜?视网膜、我该、观点、Interface

2023-09-11 07:42:28 作者:一个人寂寞

我要那么它出现在中心两个3.5和4个视网膜屏幕来定位一个UIView。什么是做到这一点的最好方法是什么?如果我关闭了所有的自动调整大小酒吧我希望它对准屏幕的中心,但是这似乎并没有发生。

I want to position a UIView so it appears in the centre on both 3.5" and 4" Retina screens. What is the best way to do this? If I turn off all the Autosizing bars I would expect it to align to the centre of the screen, but this doesn't seem to happen.

我很乐意使用新的自动布局,但我不知道如何得到它要么做到这一点。

I am happy to use the new Autolayout, but I don't know how to get it to do this either.

推荐答案

按照以下步骤为您的厦门国际银行,你应该得到正确的调整大小为您的看法:

Follow these steps for your XIB and you should be getting the correct resizing for your views:

有关无缝iOS4的兼容性,通过设置在顶视图大小为3.5的Retina规模启动。

For seamless iOS4 compatibility, start by setting the top view Size to Retina 3.5 size.

删除的俯视图的尺寸参数,并将其设置为无。您现在应该有正确的尺寸,但没有一套固定的大小选择一个主视图。

Remove the size parameter for the top view and set it to "none". You should now have a main view with the correct size but without a fixed set size option.

打开垂直自动调整大小全部为大小检查选项卡下的俯视图。

Turn on all autosizing vertically for the top view under the "Size inspector" tab.

对于每个子视图做以下

选择视图并转到尺寸检查标签 选择安排(中心垂直或对齐) 如果你想让它居中,取出两个对准标记的自动调整大小框。选择其中的一个,如果你想让它粘或两者如果你想它来填充母。 选择是否将其相对还是不调整大小以突出或unhighlighting垂直双尖箭头 确保所有的元素都位于其预期的地方在3.5的观点在这一点 - 这是至关重要的,它的工作对iOS4的

保存更改。检查您是否成功与你的自动调整大小选择的俯视图,并选择大小:视网膜4全屏。如果这样做,您认为应该像你预期的结果。

Save your changes. Check if you were successful with your autoresizing by selecting the top view and choose size: "Retina 4 Full Screen". When doing this, your view should look like your intended result.

撤消5的变化(因此,在厦门国际银行认为有3.5的大小了,但在大小选项设置为无,保存并运行你的应用程序。

Undo the change in 5 (so that the view in the xib has the 3.5 size again, but the Size option set to "None", save and run your app.

这适用于iOS4的也,因为视图的尺寸已经适合于视网膜3.5因此没有自动定大小被用于较旧的屏幕尺寸。

This works for iOS4 also, because the size of the view is already adapted for Retina 3.5 thus no autosizing is used for the older screen size.

在某些情况下,这是不可能得到确切的右尺寸/定位为所有的元素。在这种情况下,你需要以编程方式更改视图尺寸为4画面尺寸的位置。

In some occasions, it is not possible to get the exact right sizes/positioning for all the elements. In these cases you need to programmatically change the views sizes position for the 4" screen size.