我创建了一个ViewController,我从我的主ViewController中调用它。我能够成功地显示viewController,但我的问题是它正处于Portrait模式,而实际上我已经在Landscape模式下创建了它。我正在加载的viewController是在一个单独的.xib文件中创建的,我从我的主应用程序调用它。这是我用来调用它的代码:
- (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];
}
让我感到困惑的是,我将.xib文件中视图的“Orientation”属性设置为IB中“Attributes Inspector”中的Landscape,但它仍然以纵向模式显示。为什么?谁能看到我做错了什么?
事先感谢所有回复的人?
答案 0 :(得分:1)
您可能需要在NextLandscapeViewController
中使用以下方法-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
如果控件未在View Controller中访问这些方法,则需要子类化导航控制器。