Ios 如何使用UIInterfaceOrientationGrait和UIInterfaceOrientationAndScapeLeft

Ios 如何使用UIInterfaceOrientationGrait和UIInterfaceOrientationAndScapeLeft,ios,objective-c,uiwebview,uiinterfaceorientation,Ios,Objective C,Uiwebview,Uiinterfaceorientation,我有一个项目,其rootViewController是UINavigationController,并且在我的项目中,只有视图控制器加载全屏UIWebView。我需要改变它的方向 我已经解决了这个问题,但有一些麻烦:当用户在视图控制器中,web视图处于横向时,然后单击“上一步”按钮,以前的视图控制器也处于横向。然而,我希望它是肖像画。有什么办法吗 如果你能读中文,我发现,谢谢。 - (NSUInteger)supportedInterfaceOrientations { return U

我有一个项目,其rootViewController是UINavigationController,并且在我的项目中,只有视图控制器加载全屏UIWebView。我需要改变它的方向

我已经解决了这个问题,但有一些麻烦:当用户在视图控制器中,web视图处于横向时,然后单击“上一步”按钮,以前的视图控制器也处于横向。然而,我希望它是肖像画。有什么办法吗

如果你能读中文,我发现,谢谢。

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

无论您需要什么样的viewcontroller,都可以保持纵向。

我尝试了许多解决方案,但正确的解决方案是:

ios 8和ios 9,无需编辑info.plist

- (BOOL) shouldAutorotate {
 return NO;
 }   



- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return (UIInterfaceOrientationPortrait |  UIInterfaceOrientationPortraitUpsideDown);
 }
UIInterfaceOrientationUnknown

无法确定设备的方向

UIInterfaceOrientationPortrait

设备处于纵向模式,设备保持直立,主页按钮位于底部

UIInterfaceOrientation上下方向图

设备处于纵向模式,但倒置,设备保持直立,主页按钮位于顶部

UIInterface方向和左视图

设备处于横向模式,设备保持直立,主页按钮位于左侧

UIInterfaceOrientationAndscapeRight

设备处于横向模式,设备保持直立,主页按钮位于右侧