2013-08-23 39 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

相關問題