我的应用程序开始颠倒

我已经工作了一段时间并且已经发布游戏的引擎现在正在启动我当前的项目,并立即按照它假设的方式旋转UIView。 我用代码创build接口,这是关于它的样子:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... CGRect screenBounds = [[UIScreen mainScreen] applicationFrame]; CGRect windowBounds = screenBounds; windowBounds.origin.y = 0.0; UIWindow* win = [[UIWindow alloc] initWithFrame:windowBounds]; win.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; UIMyView* view = [[UIMyView alloc] initWithFrame:screenBounds]; UIMyViewController* controller = [[UIMyViewController alloc] init]; controller.view = view; view.multipleTouchEnabled = true; view.windowWrapper = this; view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; [win addSubview:view]; ... } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation; { s32 validOrientations = ((cViewMM*)(self.view)).windowWrapper->GetValidOrientations(); if (toInterfaceOrientation == UIInterfaceOrientationPortrait && (validOrientations & 0x01)) return true; if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown && (validOrientations & 0x02)) return true; if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft && (validOrientations & 0x04)) return true; if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight && (validOrientations & 0x08)) return true; return false; } 

只有当我想在UIInterfaceOrientationLandscapeLeft中启动应用程序时,问题才会发生。 通过应用程序进行debugging时,它看起来像当我试图将我的视图添加到窗口内部的shouldAutorotateToInterfaceOrientation:被多次调用。 首先用UIInterfaceOrientationPortrait返回false,然后UIInterfaceOrientationLandscapeRight返回true(因为它的有效方向),然后UIInterfaceOrientationLandscapeLeft也返回true(因为它是有效的方向,它是设备的当前方向)。

哦,更具体的这只发生在iPhone上,而不是在iPad上。 他们使用相同的代码来设置这个视图。

我究竟做错了什么?

– 编辑 –

好的,我错了shouldAutorotateToInterfaceOrientation的执行:它执行3次UIInterfaceOrientationPortrait,2次UIInterfaceOrientationLandscapeLeft,然后一次UIInterfaceOrientationLandscapeRight,再次一次UIInterfaceOrientationLandscapeLeft。

GameCenter现在正在初始化,因为它推动了一些额外的用户界面,我认为这可能是它,但事实并非如此。

检查您的Info.plist中支持的方向arrays是否以纵向(右侧)开始。 如果从任何不同的方向开始,您的应用程序将以该方向启动。

我遇到了同样的问题,很遗憾看不到答案。 然后我意识到一个关键的事情就是certificate这是事情的方式:Default.png的启动镜像也是颠倒的。 在你的应用程序中没有任何东西可以解决这个问题。 您可以select哪个风景模式正确启动(左侧或右侧的主页button),但不能使它们同时工作。

find解决scheme!

很明显,Interface Builder中有一个bug。 如果您只需单击所有方向,然后按照所需的顺序再次点击Info.plist即可正确构build。

在我的情况下,它作为tgunr说,但我必须从模拟器文件夹中删除整个应用程序,否则,方向的变化不起作用。