简体   繁体   English

自动布局混乱

[英]Autolayout confusion

Here are my views with constraints.这是我有限制的观点。

The problem is in landscape mode.问题出在横向模式。 For example, the purple view's height is 58.33(portrait mode), but in landscape mode is 36.33.例如,紫色视图的高度为 58.33(纵向模式),但在横向模式下为 36.33。 But on iPad or iPhone 12 pro max, these two are equal.但是在 iPad 或 iPhone 12 pro max 上,这两者是相等的。

在此处输入图片说明

  1. Why they are different if the constraints are the same?如果约束相同,为什么它们不同?
  2. How can I set them to be the same (purple view's height in landscape mode and in portrait mode)?如何将它们设置为相同(横向模式和纵向模式下的紫色视图高度)?

Try this out: choose a button and setup its "Content Compression Resistance Priority" to 1000 (Required)试试这个:选择一个按钮并将其“内容压缩阻力优先级”设置为 1000(必需)

Btw.顺便提一句。 SceneView is changing during rotation as well. SceneView 也在旋转过程中发生变化。 It looks you've got other constraints to satisfy with a higher priority taking into account both of these views don't have a fixed height and completely defined by its content (intrinsic) sizes are subjects for stretching and squeezing when necessary And first two vertical constraints from a screen look a bit unclear考虑到这两个视图都没有固定的高度并且完全由其内容(内在)定义,因此看起来您还有其他约束需要满足更高的优先级,并且在必要时可以进行拉伸和挤压,并且前两个是垂直的屏幕上的限制看起来有点不清楚

The problem was that this storyboard was a container view in the "X" storyboard and the "X" storyboard had several constraints related to this storyboard.问题是这个故事板是“X”故事板中的一个容器视图,而“X”故事板有几个与这个故事板相关的约束。 That was the problem.那就是问题所在。 :) :)

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

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