简体   繁体   English

iPad OpenGL屏幕旋转问题(多任务栏和弹出窗口不旋转)

[英]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. 我正在使用OpenGL构建iPad的应用程序,并且屏幕旋转出现问题。 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. OpenGL使用转换矩阵处理应用程序的旋转。 That all works fine. 一切正常。 The default images also display at the correct rotation. 默认图像也会以正确的旋转显示。

The multitask bar, however, is not rotating as it should. 但是,多任务栏未按应有的方式旋转。 It 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. 显示此条时,OpenGL应用程序将旋转以匹配条的位置。

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. 如果有人有更好的解决方案,我还是想听听,否则,希望这可以对其他人有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM