0

我有一个UINavigationController包含一些UIViewController......所有这些UIVienController都应该只在肖像模式下。

但只有其中之一UIViewController,我应该presentModalViewController。这modalViewController应该允许在所有方向上旋转。没问题,直到我想解雇这个modalViewController

如果我关闭它时它modalViewController处于横向模式。parentViewController不要回到肖像。

我怎样才能强制我的旋转parentViewController?我尝试了一些解决方案,但我无法使其工作。有什么建议吗?

4

1 回答 1

0

由于您在解雇时向您展示您modalviewcontroller的信息,否则不会调用方法。presentModalViewControllermodalviewcontrollerviewWillApperviewDIdAppear

您必须在您的UIViewControllerviansnotifcation或中调用方法delegate pattern

因此,当您关闭modalviewcontroller通知UIViewController并调用yourmethod时,yourmethod检测当前方向,如果不是纵向,则将其更改为纵向。

-(void) yourmethod 
{
    if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft || [[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight )
    {
       [[UIApplication sharedApplication] setStatusBarHidden:NO];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
    } 

} 
于 2013-04-17T15:32:26.757 回答