4

我想强行在风景中显示一个视图。所有其他视图都是纵向的。

我尝试了下面的代码来显示来自纵向模式的横向模式。它不工作。

我怎样才能做到这一点?

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        if ((interfaceOrientation == UIInterfaceOrientationMaskLandscape) ||
            (interfaceOrientation == UIInterfaceOrientationMaskLandscapeLeft) ||
            (interfaceOrientation == UIInterfaceOrientationMaskLandscapeRight))
        {
            return YES;
        }
        return NO;
    }

    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        return UIInterfaceOrientationLandscapeRight;
    }

    -(BOOL)shouldAutorotate{
        return NO;
    }

    -(NSInteger)supportedInterfaceOrientations{
        return UIInterfaceOrientationMaskLandscape;
    }
4

0 回答 0