具有不同方向的UINavigationcontroller

时间:2012-02-14 17:27:10

标签: objective-c ios uinavigationcontroller

我想创建一个带有主视图控制器和详细视图控制器的UINavigationController。

主视图控制器可以在Portrait和LandscapeRight中旋转,而细节视图控制器只能在LandscapeRight中查看(细节显示电影)。

设置此功能的最佳方式是什么?

2 个答案:

答案 0 :(得分:2)

我建议添加以下代码行

在主视图控制器上:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

     return interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}

并在您的详细信息视图控制器上

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

     return interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}

这应该可以解决问题。

答案 1 :(得分:0)

在iOS 7中,方法

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 

已被弃用。但是你可以使用

- (BOOL)shouldAutorotate

简单地返回是/否。

然后你可以告诉viewcontroller在

中可以接受哪些方向
- (NSUInteger)supportedInterfaceOrientations
相关问题