xcode/iOS: Autoresize to fill a view – explicit frame size is essential?

Autoresizing does not mean that the subview will take up the size of its superview. It just means that it will resize relative to the size change of its superview whenever the superview’s bounds change. So initially, you have to set the size of the subview to the correct value. The autoresizing mask will then … Read more

Set UIView’s autoresizing mask programmatically?

To achieve what you have in that screen shot you need to do the opposite of what DrummerB suggests. You want a fixed top margin so you make every other side flexible like so: Objective C: view.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin; Not setting a side as flexible means that it will be fixed … Read more

How to use UIView autoresizingMask property programmatically?

When setting the autoresizing mask for a view, use a bitwise inclusive OR (|) (Objective-C), or an array (Swift 2, 3, 4) to specify springs and struts. Springs are represented by specifying a mask (Objective-C or Swift, respectively): vertical spring: UIViewAutoresizingFlexibleHeight or .flexibleHeight horizontal spring: UIViewAutoresizingFlexibleWidth or .flexibleWidth Struts are represented by the lack of … Read more

Unable to simultaneously satisfy constraints – No constraints in place

Let’s look at these one by one. “<NSAutoresizingMaskLayoutConstraint:0x84543d0 h=–& v=–& V:[UIView:0xa330270(768)]>” This is saying view 0xa330270 (A) must be 768 points high. “<NSLayoutConstraint:0xa338350 V:[UIView:0xa331260]-(-1)-| (Names: ‘|’:UIView:0xa330270 )>” This is saying view 0xa331260 (B)’s bottom edge must be a gap of -1 from the bottom of A, which is it’s superview. “<NSLayoutConstraint:0xa338390 V:|-(841)-[UIView:0xa331260] (Names: ‘|’:UIView:0xa330270 )>” … Read more

Autoresizing masks programmatically vs Interface Builder / xib / nib

Yes, you have cited things correctly. Also, I agree that it feels a bit backwards, so for that reason I appreciate your post. You might like using a preprocessor Macro UIViewAutoresizingFlexibleMargins when making a UIView’s margin flexible in every direction. I put this in the precompiled header file so it gets included everywhere. #define UIViewAutoresizingFlexibleMargins … Read more