Search code examples
iphonecocoa-touchipaduiinterfaceorientation

iPad landscape modal view incorrectly sized


I have a iphone app where I want to present one of the views modally in landscape mode only and have set the code below its view controller. All works fine on the iphone (its intended platform), but when run on the iPad for demonstration, the left hand edge of the landscape view is truncated by approx 10 pixels. i.e. it looks like the display is too wide for the screen. No other views are affected and the same thing happens at 1x or 2x zoom.

Is this a bug or have I missed something?

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

Solution

  • InterfaceOrientation can return "unknown" value, in these cases you can encounter the case that the iPad thinks it is rotated and your code will return the wrong result