Reputation: 33421
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.
Upvotes: 2
Views: 363
Reputation: 34205
Not sure about others, but on the autoresizingMask
, flexibleMaxX
unsets bit 4, and flexibleMaxY
unsets bit 6.
The cocotron project lists them as:
enum {
NSViewNotSizable=0x00,
NSViewMinXMargin=0x01,
NSViewWidthSizable=0x02,
NSViewMaxXMargin=0x04,
NSViewMinYMargin=0x08,
NSViewHeightSizable=0x10,
NSViewMaxYMargin=0x20
};
Upvotes: 0
Reputation: 385960
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.
Upvotes: 0