1

通常,我的应用程序以纵向模式显示所有视图,但报告视图除外。仅当我在设置视图中并将设备旋转到横向模式时才会显示报告视图。现在,当我再次将设备旋转到纵向模式时,报告视图被关闭并显示设置视图。

In report view 

> shouldAutorotateToInterfaceOrientation

return ((interfaceOrientation == UIInterfaceOrientationLandscapeRight)||( interfaceOrientation == UIInterfaceOrientationLandscapeLeft));



Here at settings view 

    shouldAutorotateToInterfaceOrientation


    if((interfaceOrientation == UIInterfaceOrientationLandscapeRight)||( interfaceOrientation == UIInterfaceOrientationLandscapeLeft))
     {  

     Report *report = [[Report alloc]initWithNibName:@"Report" bundle:[NSBundle mainBundle]]; 
     [self.navigationController pushViewController:report animated:YES];
     [report release];

     }
     return YES;
     }
4

1 回答 1

1

不要在 shouldRotate... 中创建视图控制器,而是在willRotateToInterfaceOrientation:duration:应该响应旋转的地方创建视图控制器。在您的shouldAutorotateToInterfaceOrientation:中,当您希望能够旋转到该方向时,只需返回 YES - 在您的情况下,看起来您想要所有方向或除 PortraitUpsideDown 之外的所有方向。

在您的willRotateToInterfaceOrientation:duration:中,您可以根据需要推送您的视图控制器或弹出它。

于 2011-01-27T20:23:52.960 回答