iOS - 强制横向定位

时间:2014-01-27 20:21:54

标签: ios iphone orientation

我一直试图解决这个问题一段时间,它可能是重复但我没有找到正确的解决方案。所以我创建了一个视图控制器,并在横向模式下构建了xib。当我尝试推动视图控制器时,它显示为肖像,但我希望它显示横向。我在代码中添加了以下方法:

- (BOOL)shouldAutorotate {
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeRight;
}

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

感谢任何帮助!

0 个答案:

没有答案
相关问题