0

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?

nonopolarity
  • 146,324
  • 131
  • 460
  • 740
  • Answer can be found here: http://stackoverflow.com/questions/2647786/landscape-mode-only-for-iphone-or-ipad – James Sep 01 '12 at 00:25
  • So I even removed the Portrait in the `plist` file, so nothing whatsoever says the app can be in Portrait mode, and therefore it is strictly a Landscape app. But I still see the width being changed, first considered as Portrait, and resize to Landscape – nonopolarity Sep 01 '12 at 00:30
  • Actually, the "icons" already changed the plist -- the one in the plist that I deleted was for the iPhone. But in any event, all Portrait for iPhone or iPad are removed... it is the same – nonopolarity Sep 01 '12 at 01:28

1 Answers1

-2

Try yo set this method to autorate interface :

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    return (interfaceOrientation != UIInterfaceOrientationPortrait);

}
Lorenzo
  • 1
  • 1