在iPhone 4查看宽度的问题? [英] View width issue in iPhone 4?

查看:192
本文介绍了在iPhone 4查看宽度的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的screen.I视图采取iPhone 5为基础screen.I给下面的约束到视图。

I have a view on my screen.I have taken iPhone 5 as base screen.I have given following constraints to the view.

1.Aspect ration to self.
2.Aspect ratio to parent view.
3.Horizontal center in container.
4.Vertical Spacing.

请检查该

下面对iPhone 5S的观点没有被拉伸到全宽,但在iPhone 4上的观点并没有完全stretched.Please告诉这里的问题。

Here on iPhone 5s the view is not stretched to full width but on iPhone 4 view is not fully stretched.Please tell the issue here.

推荐答案

好吧,我重新创建你的约束和是能够复制您的问题。这是很简单的,并且由宽高比约束造成的SuperView。

Ok, I recreated your constraints and was able to replicate your problem. It is quite simple, and is caused by the aspect ratio constraint to superview.

如你所见,约束是文本字段宽度来上海华高度与比例320:568。因为我们已经知道上海华的高度绘制文本框的时候,我们需要解决这个方程,得到的文本字段宽度

As you can see, the constraint is for text field width to superview height with ratio 320:568. Because we already know the height of superview when drawing the textfield, we need to solve this equation, to get text fields width :

    320        textfield.width
   -----  =  -------------------
    568   =    superview.height

所以在iPhone 5,上海华的高度(全屏视图的情况下,当然)568 - 让我们知道,文本框的宽度应该是320 iPhone 4上,另一方面高度为480申请方程,并求解 textfield.width 我们得到270.所以,它实际上不应该被拉长。

So on iPhone 5, the height of superview (in case of full screen view, of course) is 568 - so we know that textfields width should be 320. On iPhone 4 on the other hand the height is 480. Applying to the equation, and solving for textfield.width we get 270. So it actually shouldn't be stretched.

有没有问题在这里,一切工作,因为它应该。

There is no "issue" here, and everything is working as it should.

如果您想要的文本字段具有相同的宽度,因为它是上海华,你应该增加一个宽度相等的约束。

If you want the text field to have the same width as it's superview, you should add an "Equal Widths" constraint.

让我知道如果你需要进一步的解释。

Let me know if you need further explanations.

这篇关于在iPhone 4查看宽度的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆