简体   繁体   English

XCode6 Interface Builder iPad问题

[英]XCode6 Interface Builder iPad issues

I am trying to build a view controller nib using XCode 6 Interface Builder. 我正在尝试使用XCode 6 Interface Builder构建视图控制器笔尖。 Currently my view controller contains only a view that I have set a dark gray background color. 当前,我的视图控制器仅包含已设置深灰色背景色的视图。 When I load it in an iPhone simulator, everything works as expected, that is the view fills the screen with the dark gray background color. 当我将其加载到iPhone模拟器中时,一切都会按预期进行,即视图以深灰色背景色填充屏幕。 When I load in iPad, the view is shifted off to the left and upward. 当我在iPad上加载时,视图将向左和向上移动。

For iPhone size classes, I am using w:Compact h:Regular. 对于iPhone大小的类,我正在使用w:Compact h:Regular。

For iPad size classes I am using w:Regular h:Any. 对于iPad尺寸的班级,我使用w:Regular h:Any。

In the Interface Builder preview, both iPhone and iPad look as they should. 在Interface Builder预览中,iPhone和iPad都应具有其应有的外观。

Here is what it looks like in the iPad simulator: 这是iPad模拟器中的外观:

在此处输入图片说明

Something else worth noting. 还有其他值得注意的地方。 The view controller shown in the image is the entire view controller. 图像中显示的视图控制器是整个视图控制器。 It's not just partially visible. 它不仅部分可见。 Any ideas why this is happening? 任何想法为什么会这样? Thanks! 谢谢!

Are you sure you are using autolayout with well setted constraints ? 您确定使用自动布局且约束设置正确吗? It seems your view controller is 300x300 pixels as in the any Size Class definition. 就像任何Size Class定义一样,您的视图控制器似乎为300x300像素。

Try to look at a button in your bottom right xib editor that looks like this 尝试查看右下角xib编辑器中的按钮,如下所示
|-□-|

If you don't set any constraint, your view is binded to no layout and will not adapt at all . 如果您未设置任何约束,则视图将不绑定任何布局,并且根本不会适应

You have to set constraints to define position (x, y) and size (width, height) with your constraints in order to make it adapting to your view controller without ambiguity. 您必须设置约束以使用约束定义位置(x,y)和大小(宽度,高度) ,以使其能够毫无歧义地适应您的视图控制器。
In your example, you just have to set every border of your view (top, left, right bottom) to match the borders of its superview. 在您的示例中,您只需要设置视图的每个边框(上,左,右下)以匹配其父视图的边框。

请应用约束条件TOP-RIGHT-LEFT-BOTTOM

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM