0

I've got a custom subclass of UIView, lets call it BottomBox.

BottomBox has override methods for:

-(void)setBounds:(CGRect)bounds;

and

-(void)setFrame:(CGRect)frame; 

with calls to [super set*:*] in each, and logging of current and new CGRects, and breakpoints in both.

BottomBox objects have the autoresizingMask set:

bottombox1.autoresizingMask =
    UIViewAutoresizingFlexibleTopMargin |
    UIViewAutoresizingFlexibleLeftMargin |
    UIViewAutoresizingFlexibleRightMargin;

and they are positioned at the bottom of the screen.

BottomBox objects contain sublayers of the main .layer property, and these sublayers are transformed, and the bounding box of these layers go outside the region of the BottomBox objects' view bounds. This causes the frame/bounds accessors to give back adjusted bounds values, which I have accounted for.

But after a device orientation change, the BottomBox objects are being resized abnormally, despite the autoresizingMask property defining no flexibility to width or height. In my experience, the height of the bounds/frame are not being adjusted, but the width is being extremely warped.

Now, I feel I am simply misunderstanding the real meaning of bounds and frames. Perhaps, in reality, they're calculated on the fly for every access, based on the subviews and sublayers.

I'd like to know if there is any other way these can be adjusted, perhaps I'm overlooking something.

1 Answer 1

0

During device rotation, any UIViewController that permits reorientation, and view resizing, affects any subviews if it's view.autoresizesSubviews is YES.

Then any subviews with any flexible resizing mask will permit the call of setFrame from within [UIView(Geometry) _applyAutoresizingMaskWithOldSuperviewSize:].

The receiver of setFrame: will receive the frame adjusted according to the autoresizing mask, properly.

In my BottomBox, there is a setFrame override, to inspect the frame argument, plus the values of the frame after calling [super setFrame:frame].

My implementation-specific notes:

For example, a 432-pixel-square rotated -120 deg, has a new bounding box of 589.
Then when the device is rotated and setFrame is called because of ANY flexible autoresizing mask constant, then setFrame receives a 589-pixel-square frame size. The rotation is silently applied and yet another outer bounding box is defined by a 803-pixel-square.

In practice, this 803 square was actually maintaining 589 pixels in height, it was not resized vertically. This is because of the auto resizing mask. and rigid bottom margin in my specific context.

So in summary, a view that originally was 432 pixels square managed to become a view bounded by an 803x589 pixel rectangle. Seriously warped.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.