2010-10-06 95 views
0

我希望只旋转多视图控制器(rootviewcontroller和viewcontroller 1,viewcontroller2,..)项目中的一个视图控制器。多视图控制器和旋转

可能吗?

我注意到我必须让rootviewcontroller启用shouldAutorotateToInterfaceOrientation。

但我更喜欢旋转的viewcontroller中的函数willAnimateRotationToInterfaceOrientation没有被触发。

回答

1

如果你有副控制器,如:

RootViewController的 FirstViewController SecondViewController ...

当RootViewController的的willAnimateRotationToInterfaceOrientation叫,你需要自己叫的FirstViewController相同的功能,SecondViewController等

例如

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { 

    [ FirstViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration ]; 
    [ SecondViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration ]; 

} 

顺便说一句,是的,你需要实现shouldAutorotateToInterfaceOrientation来说如果YES或NO控制器应该旋转。

祝你好运!

+0

谢谢。是否有可能只使FirstViewController旋转,rootViewcontroller和其他人不旋转? – arachide 2010-10-08 04:47:57

+0

Hummm如果FirstViewController位于rootViewcontroller内部,那么如果FirstViewController执行相同操作,rootViewcontroller将旋转。尝试在每个控制器中使用shouldAutorotateToInterfaceOrientation来说明是否可以旋转。如果你可能有一些情况会打扰你^^有时你必须做出选择^^顺便说一下,看看http://www.geckogeek.fr/iphone-forcer-le-mode-landscape-ou-portrait -en-cours-dexecution.html(法语,但用英文编码)。在某些情况下,它可以帮助您旋转一些控制器。 – Vinzius 2010-10-08 06:47:19