1

我的程序只使用横向模式。早些时候我使用了 xcode 4.5,但现在它不工作了,现在我使用了 xcode 5。模拟它旋转四边。

我只需要左右风景。

在我的应用程序委托中,我放了

 - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeLeft;//|UIInterfaceOrientationLandscapeRight;
}

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


-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

- (BOOL)shouldAutorotate{
    if([[UIDevice currentDevice] orientation] == UIInterfaceOrientationLandscapeLeft ||[[UIDevice currentDevice] orientation] == UIInterfaceOrientationLandscapeRight)
    {
        return YES;
    }
    else{
        return NO;
    }
}

在我放置的每个视图控制器中

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

在此处输入图像描述

我设置的每个故事板视图控制器和导航视图控制器都是这样设置的。 在此处输入图像描述 我怎么解决这个问题

4

1 回答 1

0

确保像这样在 appDelegate 中将 Top Most 控制器添加为 rootViewController

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {  
        navigation=[[UINavigationController alloc]initWithRootViewController:self.viewController];  
        [self.window setRootViewController:navigation];  
    } 
于 2013-11-12T04:27:12.990 回答