简体   繁体   English

IOS Swift中AutoLayout中的对齐问题

[英]Alignment Issue in AutoLayout in IOS Swift

I have 3 sections, Top Banner with Logo, Mapview in the middle and then a few labels under the MapView. 我有3个部分,带有徽标的顶部横幅,中间是Mapview,然后是MapView下的几个标签。

I have used Constraints for accomplishing this for 6s sizes. 我使用约束来完成6s大小的操作。 But when I try this out for 4s, 5, 5s the below section the Labels is not seen on the screen. 但是,当我尝试以下4s,5、5s时,屏幕上看不到标签。 In design view they are also only partially shown and seems to be somewhere hidden in 4 and 5 ios versions. 在设计视图中,它们也仅部分显示,并且似乎隐藏在4和5 ios版本中。

I have set height for the Top banner as 0.2 with the SuperView and MapView with 0.4 and trying to get the remaining labels to fill in the remaining 0.4 height of the total SuperView. 我已将SuperView和MapView的“顶部”横幅的高度设置为0.2,并用0.4设置了高度,并尝试获取剩余的标签以填充总SuperView的剩余0.4高度。 I have tried to contain all the labels in a Tableview also this is not even showing anything in Design time or even at runtime. 我试图将所有标签都包含在Tableview中,这甚至在设计时甚至在运行时都没有显示任何内容。 Another Approach is to Add a view in which place all the labels so that can add a contraint of 0.4 height for the view. 另一种方法是添加一个放置所有标签的视图,以便可以为该视图添加0.4高度的约束。 But all in vain. 但是都是徒劳的。

Layout Design : 版图设计 :

http://imgur.com/aIjBJsq http://imgur.com/aIjBJsq

I am an iOS and auto layout Noob so it maybe something silly that I might have missed. 我是iOS和自动版面设计的Noob,所以我可能错过了一些愚蠢的事情。 Appreciate any help or advise on the same 感谢任何帮助或建议

Ok, first it seems that you need a break down of the fundamentals of Auto Layout. 好的,首先,您似乎需要分解自动版式的基础知识。 Below are some resources that can help you with that. 以下是一些可以帮助您的资源。 Working with Auto Layout can take quite a bit of effort so you really should get a solid understanding, otherwise you will constantly be running into problems. 使用“自动版式”可能需要花费很多精力,因此您确实应该有扎实的了解,否则您将不断遇到问题。

Key to understanding your issues is the role layout constraints play in your design. 理解问题的关键是布局约束在设计中所扮演的角色。 You use them to make small to medium changes, for bigger changes such as different devices you need to use size classes as well as constraints. 您可以使用它们进行从小到中的更改,对于较大的更改(例如,不同的设备),您需要使用大小级别和约束。 In Xcode 8's Interface Builder you have the option to set the device for your layout, see the picture below. 在Xcode 8的Interface Builder中,您可以选择为布局设置设备,请参见下图。 It's in the bottom left-hand corner. 在左下角。 The device's selection relates to size classes. 设备的选择与尺寸等级有关。

在此处输入图片说明

So how do we go about solving your issues? 那么我们如何解决您的问题呢? We would start by laying out the view for a selected device in interface builder, then we would select another device, say iPhone 4s and then make any adjustments to your view there. 我们将首先在界面生成器中布置选定设备的视图,然后选择另一个设备,例如iPhone 4s,然后在此处对您的视图进行任何调整。 This is the basic outline and there are many steps in between. 这是基本大纲,并且介于两者之间。 The single best step you can take at this point is to get a better understanding of Interface Builder. 此时,您可以采取的最好的单个步骤是更好地了解Interface Builder。 Learning how to use interface builder will touch on all the areas covered by the resources listed above. 学习如何使用界面生成器将涉及上面列出的资源所涵盖的所有领域。

I understand this is a broad answer to your question, but I am trying to help you build an understanding of the concepts, so you can happily build your own layouts from here on out! 我知道这是对您的问题的广泛回答,但是我正在努力帮助您加深对概念的理解,因此您可以从这里开始愉快地构建自己的布局!

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

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