Ios5 如何在iOS应用程序中的通用应用程序中修复iPad的景观?

Ios5 如何在iOS应用程序中的通用应用程序中修复iPad的景观?,ios5,Ios5,通过使用我开发的Xcode4.5通用应用程序,我想让iPad版本只在横向模式下运行 我累了 - (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad && UIInterfaceOrientationIsLandscape(in

通过使用我开发的Xcode4.5通用应用程序,我想让iPad版本只在横向模式下运行

我累了

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad && UIInterfaceOrientationIsLandscape(interfaceOrientation)) 
    {
        return YES;
    } else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && UIInterfaceOrientationIsPortrait(interfaceOrientation)) 
    {
        return YES;
    }

    return NO;    
}

尽管我尝试了上面的代码,但它确实是以纵向模式出现的。

您是在ios5还是ios6中测试它?在ios6中,应自动旋转方法被忽略。你需要使用

-(NSUInteger) supportedInterfaceOrientations {

}

你可以在这里找到更多关于这方面的信息:

-(BOOL) shouldAutoRotate {
}