For the More Curious: Debugging Using the Auto Layout Trace

In this chapter, to check for an ambiguous layout, you iterated over the subviews of BNRDetailViewController’s view, and then asked each subview if it hasAmbiguousLayout. This worked well since all of the views you were working with were subviews of the main view. What if your view hierarchy was much more complex? There is another way to find ambiguous layouts using some private methods that Apple has made known.

UIWindow has a private instance method named _autolayoutTrace. This will return a string with a graphical representation of that window’s entire view hierarchy, and will tag views with an ambiguous layout with AMBIGUOUS LAYOUT.

The best way to use this is ...

Get iOS Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.