自動布局中的錯誤可分為三大類:
* 不可滿足的布局。 您的布局沒有有效的解決方案。 有關更多信息,請參閱 [Unsatisfiable Layouts](https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/ConflictingLayouts.html#//apple_ref/doc/uid/TP40010853-CH19-SW1) 。
* 模棱兩可的布局。 您的布局有兩個或更多可能的解決方案。 有關更多信息,請參閱 [Ambiguous Layouts](https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/AmbiguousLayouts.html#//apple_ref/doc/uid/TP40010853-CH18-SW1) 。
* 邏輯錯誤。 布局邏輯中存在一個錯誤。 有關更多信息,請參閱 [Logical Errors](https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/LogicalErrors.html#//apple_ref/doc/uid/TP40010853-CH20-SW1)。
大多數時候,真正的問題只是確定出了什么問題。 您添加了您認為需要的約束,但是當您運行應用程序時,事情并沒有像您希望的那樣結果。
通常,只要您了解問題,解決方案就很明顯。 刪除沖突的約束,添加缺少的約束,并調整綁定的優先級,以便有明顯的贏家。 當然,達到可以輕松理解問題的程度可能需要一些試驗和錯誤。 像任何技能一樣,通過練習變得更容易。
然而,有時事情變得更復雜。 這就是 [Debugging Tricks and Tips](https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/DebuggingTricksandTips.html#//apple_ref/doc/uid/TP40010853-CH21-SW1) 章節的用武之地。
>原文地址
>[Types of Errors](https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/TypesofErrors.html#//apple_ref/doc/uid/TP40010853-CH17-SW1)