简体   繁体   中英

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 :

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.

On iphone 4 - the view's dimension become :

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

On iphone 5/6 they become :

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

So, Y is different.

ViewController does not use navigation bars or anything else.

  1. Why on iphone 4 they are different than the one's on IB?
  2. Why that difference between 4 and 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?
  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. You may take a look official Apple documentation for reference

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

在此处输入图片说明

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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