2012-08-01 17 views
0

我的应用程序出现问题。 我想锁定特定视图上的旋转。为此,我使用了包含两个自定义viewController的rootviewcontroller。 我尝试重写我的两个viewcontrollers shouldAutorotateToInterfaceOrientation方法,但如果我允许所有的旋转我的rootViewController,我所有的viewcontrollers可以像我的rootviewcontroller旋转,我不明白为什么。RootviewController和viewControllers旋转

其实我使用这种配置:

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的),为什么我不能重写此方法? 我能做些什么?

感谢

+0

这样做不是一个好习惯。 :(你应该支持所有单独的'UIViewController'的可用方向,你推入你的应用程序......只是为了你的用户。:) – holex 2012-08-01 13:52:05

回答

1

RootViewController的和FirstCustomViewController关系正好推视图或模式,有何看法?如果关系是push-view,则所有的子视图旋转都依赖于根视图。

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

+0

谢谢你的回答。你是真的,我不使用模态视图,这就是为什么我有这个问题。随着你的解释,我知道为什么,是我的错误。我将使用模态视图。非常感谢 – tryp 2012-08-01 14:02:30