O'Reilly logo

Cocoa Programming for OS X: The Big Nerd Ranch Guide by Aaron Hillegass, Adam Preble, Nate Chandler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required