views:

157

answers:

2

I a have a following line of code invoked after a touch gesture has completed:

CGRect parentBounds = self.view.bounds;
CGRect parentFrame = self.view.frame;

when iPad is placed in a vertical way both parentFrame and parentBounds have similar dimensions of w:768 h:1004 (or something close to that), but when I rotate parentBounds is 1024x748 while parentFrame is 768x1024. Is this behavior normal? I thought I understood the concepts beetwen frames and bounds (and how they relate to each other)... but now I am really confused.

Could anyone explain what is happening with frame and bounds of a window (superview) when rotation occurs?

A: 

This is not a complete answer, but might help if you don't get something better: When the device is rotated, the top-level window's frame does not change. Instead, a transform gets applied that rotates everything 90 degrees (or 180 degrees), and then the subviews will get resized to fit in the new coordinate system.

Kristopher Johnson
A: 

The window does not change orientation; the root view does. It does this by applying a view transform (self.view.transform). You're not supposed to call frame if transform is not CGAffineTransformIdentity.

tc.