Objective c 不同方向的导航控制器
我想创建一个UINavigationController,包括一个主视图控制器和一个局部视图控制器 主视图控制器可以在纵向和LandscapeRight中旋转,而局部视图控制器只能在LandscapeRight中查看(局部显示电影)Objective c 不同方向的导航控制器,objective-c,ios,uinavigationcontroller,Objective C,Ios,Uinavigationcontroller,我想创建一个UINavigationController,包括一个主视图控制器和一个局部视图控制器 主视图控制器可以在纵向和LandscapeRight中旋转,而局部视图控制器只能在LandscapeRight中查看(局部显示电影) 设置此项的最佳方法是什么?我建议添加以下代码行 在主视图控制器上: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
设置此项的最佳方法是什么?我建议添加以下代码行 在主视图控制器上:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}
在详细视图控制器上
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}
在iOS 7中,这个方法
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
已被弃用。但是,您可以使用
- (BOOL)shouldAutorotate
只需返回是/否
然后,您可以告诉viewcontroller中哪些方向是可接受的
- (NSUInteger)supportedInterfaceOrientations
天哪,要是这么简单就好了。