iPad OpenGL Screen Rotation Problems (Multitasking bar and Popups not Rotating)
I'm building an application for the iPad using OpenGL and have issues with screen rotation. The application itself works fine and displays correctly in all four orientations, but other elements only partially respond to the device rotation.
OpenGL handles the rotation of the application using transformation matrices. That all works fine. The default images also display at the correct rotation.
The multitask bar, however, is not rotating as it should. It 开发者_StackOverflow社区appears on the side that the application was opened in. So if I open the application then double tap the home button it is on the correct side, but after rotating the device it remains on the same side until the application is closed and reopened. When this bar is revealed the OpenGL application rotates to match the bar's position.
Dialogue boxes, such as the 'sign into game center' popup are also not correctly rotated. They seem to appear in the standard portrait orientation.
I'm not sure if there are any other specific details necessary to identify the problem but any suggestions are very much appreciated.
I seem to have put together a solution looking at snippets in some other threads. I think it's fixed the problem.
I have a main class which controls most of my application. It was already registered to receive device rotation notifications like this:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
I added a few lines to the orientation handler function to manually set the status bar location:
- (void) updateOrientation { if ([[UIDevice currentDevice] orientation] < 5 && [[UIDevice currentDevice] orientation]>0) { orientation = [[UIDevice currentDevice] orientation]; [UIApplication sharedApplication].statusBarOrientation = orientation; } }
The conditional limits the handler to respond only to landscape and portrait orientations and not face up and face down.
If anybody has a better solution I'd still like to hear it, otherwise, hope this can help someone else.
精彩评论