简体   繁体   English

在没有自动布局的情况下,视图在iPhone 4和5/6上的位置不同

[英]View has different position on iphone 4 and 5/6 without Auto-layout

I am not using auto-layout but I have a view on storyboard (using the interface builder) which on the view attributes has this : 我没有使用自动布局,但我在情节提要板上有一个视图(使用界面生成器),该视图在view属性上具有以下内容:

X : 0 , Y : 43, Width :325, Height : 362.

I am not using auto-layout and the view on the IB has a fixed simulated size. 我没有使用自动布局,并且IB上的视图具有固定的模拟大小。

On iphone 4 - the view's dimension become : 在iPhone 4上,视图的尺寸变为:

ContainerView. X : 0.000000 Y:63.000000 Height :362.000000 Width : 325.000000

On iphone 5/6 they become : 在iPhone 5/6上,它们变为:

ContainerView. X : 0.000000 Y:151.000000 Height :362.000000 Width : 325.000000

So, Y is different. 因此,Y是不同的。

ViewController does not use navigation bars or anything else. ViewController不使用导航栏或其他任何东西。

  1. Why on iphone 4 they are different than the one's on IB? 为什么在iPhone 4上它们与IB上的不同?
  2. Why that difference between 4 and 5/6? 为什么4和5/6之间有这种差异? I guess because of the different screen size and the difference in status bar - but that difference is not 88 pt, isn't it? 我猜是因为屏幕尺寸不同以及状态栏的不同-但是这种差异不是88 pt,不是吗?
  3. What's the best way to have it on the same position ? 将其置于相同位置的最佳方法是什么? Programmatically check the device and adjust the frame or use auto-layout? 以编程方式检查设备并调整框架或使用自动布局?

Thanks 谢谢

If you disable AutoLayout this means you are using Autoresizing which has limited feature of adapting your view to size and orientation changes. 如果禁用“自动版式”,则意味着您正在使用“自动调整大小”,该功能具有使视图适应大小和方向变化的有限功能。 Check your Autoresizing masks 检查您的自动调整大小的面具

在此处输入图片说明

Recommended way to use AutoLayout with size classes so you can fine tune all the UI components according to different size and orientation. 推荐的将AutoLayout与尺寸类结合使用的方法,以便您可以根据不同的尺寸和方向微调所有UI组件。 You may take a look official Apple documentation for reference 您可以看一下Apple的官方文档以供参考

https://developer.apple.com/library/ios/recipes/xcode_help-IB_adaptive_sizes/chapters/AboutAdaptiveSizeDesign.html https://developer.apple.com/library/ios/recipes/xcode_help-IB_adaptive_sizes/chapters/AboutAdaptiveSizeDesign.html

在此处输入图片说明

在此处输入图片说明

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

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