如何保持iPad屏幕处于横向模式

如何保持iPad屏幕处于横向模式,ipad,Ipad,我有一个应用程序,我想在iPhone和iPad上运行。但我希望iPad屏幕处于横向模式。 为此,我在ViewController.m文件中编写了以下代码,并在.plist文件中以横向模式设置方向。但它仍然以纵向模式显示屏幕 所以,请帮助我在横向模式下设计屏幕 多谢各位 // iOS6 - (BOOL)shouldAutorotate { return NO; } // iOS6 - (NSUInteger)supportedInterfaceOrientations { if

我有一个应用程序,我想在iPhone和iPad上运行。但我希望iPad屏幕处于横向模式。 为此,我在ViewController.m文件中编写了以下代码,并在.plist文件中以横向模式设置方向。但它仍然以纵向模式显示屏幕

所以,请帮助我在横向模式下设计屏幕

多谢各位

// iOS6
- (BOOL)shouldAutorotate {
    return NO;
}

// iOS6
- (NSUInteger)supportedInterfaceOrientations {
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        return (UIUserInterfaceLayoutDirectionLeftToRight || UIUserInterfaceLayoutDirectionRightToLeft);
    } else {
        return UIInterfaceOrientationMaskLandscape;

    }

}

// Added after comment
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeLeft;
}

在.m文件中添加以下内容

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