Bartosz Bialecki
Bartosz Bialecki

Reputation: 4451

iOS AutoLayout Ambiguous Layout in NavigationViewController

I have a navigation view controller, this view has only main view and when I trace auto layout I see this:

*<UIWindow:0x8a9de40> - AMBIGUOUS LAYOUT
|   *<UILayoutContainerView:0x8bb7a50>
|   |   *<UINavigationTransitionView:0x8bbbfd0>
|   |   |   *<UIViewControllerWrapperView:0x8bc55c0>
|   |   |   |   *<UIView:0x8bc4670>
|   |   |   |   |   *<_UILayoutGuide:0x8bc46d0> - AMBIGUOUS LAYOUT
|   |   |   |   |   *<_UILayoutGuide:0x8bc4990> - AMBIGUOUS LAYOUT
|   |   <UINavigationBar:0x8a94480>
|   |   |   <_UINavigationBarBackground:0x8a9c790>
|   |   |   |   <_UIBackdropView:0x8bb82c0>
|   |   |   |   |   <_UIBackdropEffectView:0x8bb7b60>
|   |   |   |   |   <UIView:0x8bba5d0>
|   |   |   |   <UIImageView:0x8a9ca90>
|   |   |   <UINavigationItemView:0x8a98370>
|   |   |   |   <UILabel:0x8a987e0>
|   |   |   <_UINavigationBarBackIndicatorView:0x8bc1d00>

Does somebody know why UILayoutGuide is ambiguous?

Upvotes: 9

Views: 1501

Answers (1)

Fruity Geek
Fruity Geek

Reputation: 7381

The layout is ambiguous because of timing. If you run the trace after the view is visible, the ambiguity is resolved. https://stackoverflow.com/a/19129807/568295

The underlying "why" is an implementation detail. I would guess they are returning UIViewNoIntrinsicMetric for the intrinsicContentSize for the placeholder views for the top and bottom layout guides until after the navigation bar is displayed.

Upvotes: 4

Related Questions