I have a xib file representing a simple view with auto-layout that I am instantiating with [[NSBundle mainBundle] loadNibNamed:@"name"][0]
and adding to a programmatically-created UIView
via addSubview:
.
The problem is that the view is not stretching to meet the size of the view it is embedded in; rather it appears to be defaulting to the size that was specified in the xib file. (I also can't find any way to set constraints on the container view itself in the xib file, only its subviews.)
Also somewhat strangely, when I rotate the iPad, the view's width further shrinks proportionately. So it's clearly wired up somehow, but with the wrong initial values.
What connection am I missing to get this embedded view to fit the view hierarchy properly?
Screenshots (magenta colouring added for debugging):
After rotating to portrait: