Guides and Sample Code

Developer

Auto Layout Guide

Types of Errors

Errors in Auto Layout can be divided into three main categories:

  • Unsatisfiable Layouts. Your layout has no valid solution. For more information, see Unsatisfiable Layouts.

  • Ambiguous Layouts. Your layout has two or more possible solutions. For more information, see Ambiguous Layouts.

  • Logical Errors. There is a bug in your layout logic. For more information, see Logical Errors.

Most of the time, the real problem is just determining what went wrong. You added the constraints you thought you needed, but when you ran the app, things did not turn out as you had hoped.

Usually, as soon as you understand the problem, the solution is obvious. Remove conflicting constraints, add missing constraints, and adjust tied priorities so that there is a clear winner. Of course, getting to the point where you can easily understand the problem may take some trial and error. Like any skill, it gets easier with practice.

Sometimes, however, things get more complicated. That’s where the Debugging Tricks and Tips chapter comes in.