UIView has portrait dimensions while in landscape?

cocoa, ios, ipad, objective-c

Solution

The frame rectangle, which describes the view’s location and size in its superview’s coordinate system.

@property(nonatomic) CGRect frame

and

The bounds rectangle, which describes the view’s location and size in its own coordinate system.

@property(nonatomic) CGRect bounds

Use bounds, not frame.

Problem

I have a storyboard with 1 `UIViewController`, holding 1 `UIView` that contains a number of nested `UIView`s. I subclassed the View Controller to implement this method: ``` - (BOOL)shouldAutorotateToInterfaceOrientation: UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft); } ``` I also added ``` <key>UISupportedInterfaceOrientations</key> <array> <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> <key>UIInterfaceOrientation</key> <string>UIInterfaceOrientationLandscapeLeft</string> ``` to the `Info.plist`. In the viewDidLoad of the main UIView I'm doing this: ``` PASectionView* sectionView = [[PASectionView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, 180)]; [self addSubview:sectionView]; ``` The problem is the control is only 756px wide instead of the expected 1024. See the screenshot below for details. I've been searching all over the web but I can't find a solution to this frustrating problem anywhere. I'm using Xcode 4.5 with iOS5.1 set as base SDK. EDIT It's working by replacing frame with bounds. However I don't understand what's happening so it isn't working with the frame size.

Original source

Related problems