【问题标题】:From Portrait mode to Landscape mode in iOS5, iOS6在 iOS 5、iOS 6 中从纵向模式到横向模式
【发布时间】:2013-02-01 10:28:14
【问题描述】:

我只想将我的应用中的一个视图转为横向。 我所有的其他视图都处于纵向模式。上一个视图处于纵向模式。我将横向视图推到纵向视图。我怎样才能正确地做到这一点?


在我的横向视图控制器中:

//Orientation
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
    return (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
// New Autorotation support
-(BOOL)shouldAutorotate {
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscapeRight;
}

【问题讨论】:

    标签: ios6 xcode4.5 autorotate landscape-portrait


    【解决方案1】:

    您可以在视图控制器中使用它

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
    }
    

    这将确保方向是正确的横向。

    【讨论】:

    • 此方法在 ios6 中已弃用
    【解决方案2】:

    要更改设备中的方向,您可以像这样求和。

    -(void)viewDidLoad
    {
        orientation = [[UIDevice currentDevice] orientation];
        if(intOrientation == UIInterfaceOrientationLandscapeRight)
                    orientation = UIDeviceOrientationLandscapeRight;
    
    }
    

    希望对你有帮助

    【讨论】:

      【解决方案3】:

      我已经解决了。谢谢桑。我用this example:

      另见this

      this

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多