1

I've worked out that the lower 6 bits correspond to the autoresizing mask of the view, but is there any harm in editing this property directly in the XIB XML? The reason I am doing it is because for whatever reason, Xcode insists on giving the root view a bad autoresizing mask (usually 292 or 256) when using auto layout, and there is no way to change this setting or the constraints on the root view (which makes sense, I guess, since there is no superview yet). It will make the view stick in portrait size, even in landscape, which defeats the purpose of auto layout.

What I want is the equivalent of flexible width and height, so that the root view always fills its parent (which is usually the root view of the UIWindow). Changing the NSvFlags so that the lower 6 bits line up that way (274) seems to do the trick, but is there a less hacky way to do that? I don't want to create a custom view just to have it fill the screen either though.

Also, What is the bit in the 9th position used for? I can't seem to find any information on this.

borrrden
  • 33,256
  • 8
  • 74
  • 109

1 Answers1

0

If you change the nib by hand, IB might change it back at any time.

Try setting the size to “Freeform” in the Simulated Metrics section of the Attributes Inspector. It's on the view if the view is a top-level object. It's on the view controller if the view is in a view controller. When I set the size to “Freeform”, I can toggle any of the view's springs and struts.

If that fails, just do it in code.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848
  • Hmmm, perhaps I wasn't clear that I am using Auto Layout, so I can't set the springs and struts like that (they are replaced by the NSLayoutConstraints, and I can't set NSLayoutConstraints on the root view either) – borrrden Oct 23 '12 at 04:33