If the app only supports Landscape mode, as specified by clicking the icons in the Project Summary, and in
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}
Then if in viewDidLoad
, I do
UIView *smallBox = [[UIView alloc]initWithFrame:CGRectMake(10, 10, 300, 300)];
smallBox.autoresizingMask = UIViewAutoresizingFlexibleWidth;
smallBox.backgroundColor = [UIColor yellowColor];
[self.view addSubview:smallBox];
Then I hold a physical iPad 2 at Landscape orientation, and run the program from Xcode. The yellow box is actually much wider than 300px. But that can only if the 300px is first considered in the Portrait mode as 300px, and then resize to fixed left and right margins, making it 556px wide. (as confirmed in a touch handler I added to print out the frame width).
But the app is configured to run only in Landscape mode, so why any resize? So it seems that the rule of iOS app is that it is always first layouted in Portrait mode, and then resize / re-layout if Landscape mode is wanted?