Cocoa Programming for OS X: The Big Nerd Ranch Guide
by Aaron Hillegass, Adam Preble, Nate Chandler
Does Not Compute, Part 2: Ambiguous Layout
A layout is ambiguous when there are not enough constraints for Auto Layout to determine the positions of all of the views. It is computationally expensive to determine whether a layout is ambiguous, so you will not see console output as with unsatisfiable constraints. However, Cocoa provides several tools for addressing ambiguous layout in the form of debugging APIs.
The most conspicuous tool is NSWindow’s visualizeConstraints(_:). When you call this method, Cocoa will decorate the window with visual representations of the constraints. This is shown in Figure 25.15.
Figure 25.15 Visualizing constraints on a window
If the layout is ambiguous, you will also see an Exercise ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access