首页 文章

状态栏保留在横向中,而UIInterfaceOrientation仅为纵向

提问于
浏览
1

我正在开发一款仅限iPhone的应用程序 . 此应用程序支持 Supported Interface Orientations 中的 portrait and landscape 方向,但在应用程序的第一个视图中,我使用以下代码禁用旋转:

- (BOOL)shouldAutorotate
{
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

现在,我的问题是当我在 iPad 上使用 iOS 6.1 启动应用程序同时将iPad保持在横向模式时,应用程序以纵向模式启动,而状态栏处于横向模式 . 此外,该应用程序不响应任何触摸 .

我已经尝试在 shouldAutorotate 的调用中返回 YES 或者通过调用 [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait] 在纵向模式下设置状态栏,但是当我这样做时,应用程序在方向上切换3次(横向 - >纵向上下颠倒 - >纵向)导致很多在启动时 flickering ,所以这似乎不是要走的路,或者是它?

1 回答

  • 1

    你在AppDelegate函数中有什么

    - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ }

    默认情况下,应用程序和视图控制器支持的界面方向设置为iPad惯用语的UIInterfaceOrientationMaskAll和iPhone惯用语的UIInterfaceOrientationMaskAllButUpsideDown .

    在supportedInterfaceOrientationsForWindow函数中检查选定的viewcontroller,然后将其设置为Portrait direction .

相关问题