简体   繁体   English

支持所有iPhone尺寸

[英]Supporting all iphone sizes

I'm trying to create a iOS app, but I'm stuck on the layout. 我正在尝试创建一个iOS应用,但是我被困在布局上。

I created the home view, but now I see that it's not shown in the right way in the 4S simulator. 我创建了主视图,但是现在我看到它在4S模拟器中没有以正确的方式显示。
I tried with size classes , but it looks like 4S and 6, for example, are in the same size class, and so I can't set a different dimension for views. 我尝试使用size类 ,但是例如4S和6看起来是在相同的size类中,因此无法为视图设置不同的尺寸。

My goal is to support all devices, also iPads. 我的目标是支持所有设备,包括iPad。 Can someone please tell me how to do it? 有人可以告诉我该怎么做吗?

尺寸类别主要用于iPad,Apple Watch和横向模式之间的分离。在potrait模式的iPhone 4至iPhone 6中,所有电话设备的尺寸均在同一类别中(常规高度和紧凑宽度)。自动布局具有许多不同的约束条件以帮助您适应界面在同一个班级中。您应考虑水平/垂直对齐,相等的宽度和宽高比约束。它们对于较小的尺寸更改非常灵活,可帮助您设计自适应布局。

You should use "Reset to Suggested Constraints" for all views in your View controller. 您应该对View控制器中的所有视图使用“重置为建议的约束”。 You can also check the simulated metrics for all devices without compiling the the code. 您也可以检查所有设备的模拟指标,而无需编译代码。 For 4s and 6 by default the size is Inferred. 默认情况下,对于4s和6,大小为Inferred。 You should try resetting the constraints to check this for iPad as well. 您还应该尝试重新设置约束条件,以便在iPad上也进行检查。

I am just sharing an idea Option1: I think You can try adaptive Layouts and in file inspector->simulated Metrics->size-> Inferred. 我只是分享一个想法Option1:我认为您可以尝试自适应布局,并在文件检查器->模拟指标->大小->推断中。 It works in all devices it supports both landscape and Portrait. 它可以在支持横向和纵向的所有设备上工作。

Option2: Go for Visual layouts they are easy to understand and they work perfect in all modes of Portrait. 选项2:选择易于理解的视觉版式,并且在所有纵向模式下都可以完美工作。

I am think that you use code Instead design in main.storyboard ! 我认为您使用代码代替main.storyboard中的设计! for ex: create button with code (and use Ratio in your code) 例如:使用代码创建按钮(并在代码中使用“比率”)

by this way i create small app for iPhone & iPad ! 通过这种方式,我为iPhone和iPad创建了一个小应用程序!

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

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