I'm writing EAGLView - based application (game) and need to add UIViewController with UIWebView in landscape mode.
What I done:
Specified UIInterfaceOrientationLandscapeRight for UIInterfaceOrientation in the Info.plist
Call [application setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO] in the applicationDidFinishLaunching
Specified shouldAutorotateToInterfaceOrientation for my ViewController class like this:
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) orientation { return [UIApplication sharedApplication].statusBarOrientation==orientation;
}
Created new ViewController and add it's view into main window subview
SViewController *VC = [[SViewController alloc] init]; [g_EAGLView.window addSubview : VC.view];
(SViewController is my class derived from UIViewController)
What I have. First time I created ViewController it's displayed correctly in landscape mode. But every next times - it's displayed only in portrait mode. After placing breakpoint in the shouldAutorotateToInterfaceOrientation and examining call stack -- I noticed that internal function UIWindow::_updateToInterfaceOrientation calls only on first ViewController creation. Then I put manual call of _updateToInterfaceOrientation each time after adding subview -- and problem disappears -- every time ViewController displayed in the landscape mode. But apparently, it's wrong way to use undocumented functions. How can I cause UIWindow::_updateToInterfaceOrientation call by documented functions only ? Or maybe I missed something with landscape mode ??
Thanks a lot.