簡體   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