【问题标题】:Status Bar remains in landscape, while UIInterfaceOrientation is only portrait状态栏保持横向,而 UIInterfaceOrientation 只是纵向
【发布时间】:2013-09-04 11:18:55
【问题描述】:

我正在开发一个仅限 iPhone 的应用程序。此应用程序在支持的界面方向中支持纵向和横向方向,但在应用程序的第一个视图中,我使用以下代码禁用旋转:

- (BOOL)shouldAutorotate
{
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

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

我尝试在对shouldAutorotate 的调用中返回YES 或通过调用[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait] 将状态栏设置为纵向模式,但是当我这样做时,应用程序在方向上切换了3 次(横向-> 纵向upsidedown -> portrait) 导致在启动时出现很多闪烁,所以这似乎不是可行的方法,不是吗?

【问题讨论】:

    标签: ios ios6 uiinterfaceorientation


    【解决方案1】:

    你在 AppDelegate 函数中有什么

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

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

    在supportedInterfaceOrientationsForWindow 函数中检查选定的视图控制器,然后将其设置为纵向。

    【讨论】:

    • 试过了,但结果和我在application:didFinishLaunchingWithOptions:中手动设置状态栏方向时一样。意思是我得到了闪烁
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多