I have a nice running HTML5 Website with some JavaScript. This Page is called in a UIWebView.
The Page runs some JavaScript to check, weather the iPad is in Portrait or in Landscape Mode.
And here is the Problem. It doesn’t matter, if the iPad is in Landscape or in Portrait-Mode, the Function call:
orientationObserver.getOrientation()
always returns “portrait”.
Is this a known Problem, or am i doing something wrong? I set the View containing the UIWebView to landscape mode with:
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation==UIInterfaceOrientationLandscapeLeft);
}
i do an:
alert(orientationObserver.getOrientation()
in the JS and it returns always “Portrait”, the device (and so the App) runs in landscape.
You can specify CSS styles based on viewport orientation: Target the browser with
body[orient="landscape"] or body[orient="portrait"]However Apple’s approach to this issue is to allow the developer to change the CSS based on the orientation change but not to prevent re-orientation completely. I found a similar question here.