RootviewController和viewControllers旋转

时间:2012-08-01 13:14:10

标签: iphone objective-c rotation viewcontroller rootview

我的应用有问题。 我想在特定视图上锁定旋转。 为此,我使用rootviewcontroller,它包含两个自定义viewControllers。 我试图在我的两个viewcontrollers上覆盖shouldAutorotateToInterfaceOrientation方法,但如果我允许rootViewController上的所有旋转,我的所有viewcontrollers都可以像我的rootviewcontroller那样旋转,我不明白为什么。

实际上我使用这个配置:

RootviewController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    //By default, i allow all rotation
   return YES
}

FirstCustomviewController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    //On my first viewController, I allow only orientation in portrait
   return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

但是在所有情况下,它允许所有旋转(我认为它来自rootviewcontroller)以及为什么我不能覆盖此方法? 我能做些什么呢?

由于

1 个答案:

答案 0 :(得分:1)

RootViewController和FirstCustomViewController的关系是推送视图还是模态视图?如果关系是推视图,则所有子视图轮换都依赖于根视图。

将UINavigationController视为房屋,将UIViewControllers视为房间。房子里的所有房间都会像房子一样旋转。没有转动房子和其他房间就无法转动房间。