HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iOS 6旋转:推动视图控制器大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想支持iOS 6轮换.麻烦的是,我一直在查看大量的文档和堆栈溢出问题,但没有找到任何甚至是稍微深入的解决方案.我只是看到我应该将这两个方法添加到我的视图控制器类中 – 但是,如果我没有弄错,它们的操作方式与iOS 6之前的方法不同:
- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll; // use what is appropriate for you.
}

我的应用程序目前使用以下@L_944_5@在iOS6之前轮换.请注意,我使用界面方向参数来确定是否要按下我的视图控制器.如何在iOS 6轮换代理中实现此功能

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    UIInterfaceOrientation toOrientation = self.interfaceOrientation;

    if ( self.tabBarController.view.subviews.count >= 2 )
    {
        UIView *tabBar = [self.tabBarController.view.subviews objectATindex:1];

        if(toOrientation != UIInterfaceOrientationLandscapeLeft && toOrientation != UIInterfaceOrientationLandscapeRight)
        {
            CUSTOM_DEBUG_LOG("\n\nRotated BACk to PorTrait");
            tabBar.hidden = falSE;
        }
    }
}

- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{
    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {
        CUSTOM_DEBUG_LOG("\nView going landscape");
        ScrollViewController *s = [[ScrollViewController alloc] initWithNibName:@"ScrollViewController" bundle:nil];
        [self.navigationController pushViewController:s animated:NO];
        [s release];
        self.tabBarController.tabBar.hidden = YES;
        self.navigationController.navigationBar.hidden = YES;
    }

}

解决方法

结帐 thisthis SO讨论.

[编辑]

是的,你提到的方法在iOS 6.0中不被弃用,它们将继续工作.这就是Auto Rotation工作方式的改变.到目前为止,视图控制器有责任决定它们是否旋转,但现在RootViewController将决定他们的孩子是否应该旋转.如果你没有rootviewcontroller设置,那么你必须将它添加到窗口然后在rootviewcontroller中放入shouldAutoRotate和supportedInterfaceOrientations方法.

大佬总结

以上是大佬教程为你收集整理的iOS 6旋转:推动视图控制器全部内容,希望文章能够帮你解决iOS 6旋转:推动视图控制器所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。