What does "autoresize = W+H;" mean in NSLog output of a UIView object

3.3k views Asked by At

Code: NSLog(@"[self view] = %@", [self view]);

Output: [self view] = <UIView: 0xca2bfc0; frame = (0 44; 320 588); autoresize = W+H; autoresizesSubviews = NO; layer = <CALayer: 0xca1d7e0>>

I tried to [[self view] setFrame:CGRectMake(0, 64, 320, 568 + 64)];, but view's frame is still frame = (0 44; 320 588). So I NSLog the [self view] to see if there is some autoresize constraints there. But don't know what does the above notation mean.

3

There are 3 answers

1
amanhuipg On BEST ANSWER

This is the log description of the UIView -autoresizingMask. Basically, it's the way you describe what subviews should do when the superview is resized. It's very powerful.

Your current rules tell the subview to resize width and height when the superview is resized, and to keep the distance above and below the subview static (in terms of the superview coordinate system).

1
kkodev On

This means that your current autoresizing mask is set to UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight

0
James Webster On

You can read that as:

This view will autoresize by stretching its width and its height.