Skip to main content

Command Palette

Search for a command to run...

nib is not showing up without specifying a size

Published
1 min readView as Markdown

When trying to use a custom nib / xib in a view controller, it kept saying "ambiguous height".

But if I gave it a height, then the custom nib would show up perfectly. And it was clear from the visual debugger, that it had an intrinsic size.

Sooo, I tried compression hugging, and also tried to get the instrinsic size. No dice.

The issue? In order for the view to work out its own height, the vertical layout needs to be unambiguous.

Turned out that I had not provided a bottom constraint.

SOO, my custom layout: It was a vertical stackview inside a UIView.

Turns out I had constrained the top, leading and trailing anchors. BUT I had forgotten to constrain the bottom anchor.

As an aside, I also changed the size to freeform, so it wasn't looking like a view controller, and I could override the nib to the size I want (though this size isn't taken into account)

image.png

11 views

More from this blog

CoderLyn's developer journey

136 posts

I'm an iOS developer, helping millennials with their finances through US neo-bank, Empower.

Before making the switch to development, I was a strategist and GM in the tech space.