2013-08-23 40 views
0

我创建了一个ViewController,我从我的Main ViewController调用。我能够成功地显示viewController,但我的问题是,它是在纵向模式下,实际上我已经在横向模式下创建它。我正在加载的viewController是在我从主应用程序调用的单独的.xib文件中创建的。下面是我用来调用它的代码:.xib文件中的ViewController在纵向模式下加载,而在iOS中不在横向模式下

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 

    NSLog(@"I was touched."); 

    _nextView = [[NextLandscapeViewController alloc] initWithNibName:@"NextLandscapeViewController" bundle:nil]; 
    [_nextView setDelegate:(id)self]; 
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:_nextView]; 
    [self presentViewController:navigationController animated:YES completion:nil]; 

} 

是困惑我的事情是,我在IB设置在的.xib文件为横向视图中的“方向”属性中的“属性检查器” ,但它仍然以肖像模式出现。为什么?任何人都可以看到我做错了什么?

在此先感谢所有回复?

回答

1

您可能需要使用下面的方法在NextLandscapeViewController

-(BOOL)shouldAutorotate 
{ 
    return YES; 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskLandscape; 
} 

如果控制没有达到在视图控制器这些方法,那么你需要继承导航控制器。

+0

非常感谢您的及时回复。它看起来像我将不得不继承我的导航控制器。但是,我只使用单个视图应用程序,而第二个视图控制器来自.xib文件。在这种情况下,我将如何划分导航控制器? – syedfa

相关问题