How to handle iPhone 4s, 5 and 6 screen size, and make all the contents look the same across al the devices

好久不见. 提交于 2019-12-21 05:47:06

问题


I am using Xcode 6.1 and in one of the views I have, contains many labels. However, these labels look different in each different devices. Although I have add constraints to all the labels, but still facing the same issue.

How can I get the same view layout across all devices? How can I make the width and height for each label is flexible, depends on the screen size? Do I need to design different xib for each device?

The following images showing the result am getting, with auto resize enabled, and constants been added.

on iPhone 6

on iPhone 5

on iPhone iOS 7.1


回答1:


We have provided with a simple solution . Using Aspect ratio constraint we can get a relative look in all device screens.

I had the same issue and I found this >> http://mathewsanders.com/designing-adaptive-layouts-for-iphone-6-plus/

So when designing for lowest to highest screen resolution we can't set a specific width and height for all controls as it may look weird. So using this constraint we can have a relative look for all screens.

If you don't want to use constraints or you want to keep the same width & height , you can add scrollview to hold all controls. For that you can set a resizing frame for scrollview with fixed content size .




回答2:


To solve this...

1) Go to xib file and uncheck the Auto layout

2) Then set the autosizing manually in the following manner for each and every subview.




回答3:


Use self.view.bounds.size.width to get the width of screen, then use relative value to initialize all labels.




回答4:


One soultion is that you can Design a story board for each screen size like one for iphone 5, one for iphone 6 and one for iphone 6+ and in your AppDelegate method "didFinishLaunchingWithOptions" you can get the screen size and popup corresponding storyboard in this wasy you can set different constraints according to different screen size



来源:https://stackoverflow.com/questions/26665028/how-to-handle-iphone-4s-5-and-6-screen-size-and-make-all-the-contents-look-the

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!