【问题标题】:upSideDown iPhone orientation is not working in iOS 6?upSideDown iPhone 方向在 iOS 6 中不起作用?
【发布时间】:2012-12-05 10:19:39
【问题描述】:

希望你一切都好,并尽力而为。

我在iOS 6upSideDown Orientation 中遇到问题,虽然我认为我做的一切都很完美,但我不知道为什么它不适合我。我正在与您分享我的问题,以便获得任何解决方案。

到目前为止我做了什么:

a) 在 xcode 项目摘要选项卡中,我已启用所有 4 个方向。

b)我在所有控制器类中添加了一段代码(如下所示)。

-(BOOL)shouldAutorotate
{
    return YES;
}
-(NSInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

upSideDown Orientation 仍然无法正常工作

感谢期待。

【问题讨论】:

    标签: objective-c ios6 xcode4.5 uiinterfaceorientation uideviceorientation


    【解决方案1】:

    我找到了解决办法。

    我们需要创建一个单独的UINavigation Controller 类型的类。在.m 文件中添加以下方法

    // Deprecated in iOS6, still needed for iOS5 support.
    // ---
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        // Return YES for supported orientations
        //    return (interfaceOrientation == UIInterfaceOrientationPortrait);
        return YES;
    }
    
    // iOS6 support
    // ---
    - (BOOL)shouldAutorotate
    {
        return YES;
    }
    
    -(NSUInteger)supportedInterfaceOrientations{
        return UIInterfaceOrientationMaskAll;
    }
    

    现在将这个新创建的课程分配给故事板中的Navigation Controller。还要在'Project -> Build Setting -> Compile Sources'中添加这个类的.m文件。运行项目,它将支持并执行所有方向,包括upSideDown

    希望对大家有帮助。

    问候

    【讨论】:

    • 另一种方法是在UINavigationController 上创建一个类别,如下所示:stackoverflow.com/a/16052448/211292
    • 我只需要 iOS 7 的 iPhone 来检测 PortraitOrientationUpSideDown。
    猜你喜欢
    • 1970-01-01
    • 2015-01-22
    • 1970-01-01
    • 2012-09-25
    • 1970-01-01
    • 2014-12-21
    • 1970-01-01
    • 1970-01-01
    • 2012-09-25
    相关资源
    最近更新 更多