按下后退按钮,我的应用程序的方向正在破坏

时间:2012-08-21 10:17:15

标签: objective-c ios xcode

我有一个iPad应用程序有一个奇怪的怪癖。我在导航控制器中使用它,当我在除了转换到的第一个屏幕之外的任何屏幕上按“返回”时,它将我的方向改为纵向。例如......

屏幕1>>屏幕2 - 如果我按回屏幕2,则转换回屏幕1没有问题。

屏幕1>>屏幕2>屏幕3 - 如果我按回屏幕3,屏幕2按纵向渲染,然后如果我再次返回,屏幕1也是如此。

在Xcode中,我进行了设置,以便应用程序仅支持正确的横向方向。我还有以下代码:

{
    if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) 
        return YES;        
    return NO;
}

那么当我按回屏幕3(或更高版本)时会发生什么?我不明白为什么它会改变方向。

提前致谢!

2 个答案:

答案 0 :(得分:0)

对所有屏幕使用以下代码

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

答案 1 :(得分:0)

您是否已检入项目设置?它应该看起来像Have you checked in Project Settings?. It should look likethis