繁体   English   中英

约束在横向方向上未按预期工作

[英]Constraints are not working as expected in landscape orientation

我仅使用自动布局使用故事板测试非常简单的布局(任何地方都没有代码)

我放下Button对象wAny,hAny,然后将size类切换到wCompact,hAny

并添加约束“在容器中水平居中”和“顶部空间到顶部布局指南”。

接下来,我将大小类切换为wAny,hCompact,并添加约束“在容器中垂直居中居中”和“在容器边距中拖尾空间”以及宽度,高度约束

这就是我添加的所有限制,情节提要中没有警告和错误。

我期望将其设为纵向居中居中的按钮,横向居中居中。

portrait正常运行,但是当我通过错误日志更改方向时,预览和模拟器向我显示了错误的结果。

像这样

Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "\<_UILayoutSupportConstraint:0x7a065db0 V:[_UILayoutGuide:0x7a067440(0)]>",
    "<_UILayoutSupportConstraint:0x7a068010 V:|-(0)-[_UILayoutGuide:0x7a067440]   (Names: '|':UIView:0x7a0661d0 )>",
    "<NSLayoutConstraint:0x7a0680b0 V:[_UILayoutGuide:0x7a067440]-(20)-[UIButton:0x7a066740'Button']>",
    "<NSLayoutConstraint:0x7a06d9e0 'UIView-Encapsulated-Layout-Height' V:[UIView:0x7a0661d0(320)]>",
    "<NSLayoutConstraint:0x7a068050 UIView:0x7a0661d0.centerY == UIButton:0x7a066740'Button'.centerY>",
    "<NSLayoutConstraint:0x7a0680e0 V:[UIButton:0x7a066740'Button'(30)]>"
)

Will attempt to recover by breaking constraint "<NSLayoutConstraint:0x7a0680e0 V:[UIButton:0x7a066740'Button'(30)]>

然后按钮填充其容器视图的宽度和高度。

我不知道我做错了什么?

我是否缺少有关自动布局(带有方向)的重要信息?

请帮我

(对不起,我的英语不好。我不是英语母语人士)

您的问题是wCompact | hAny适用于纵向或横向iPhone。 因此,由于所有约束都适用,因此最终导致景观中的约束冲突。 您应该为iPhone纵向使用wCompact | hRegular

暂无
暂无

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

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