UIInterfaceOrientation

UIInterfaceOrientation

我尝试检查当前显示的视图控制器的UIInterfaceOrientation,由于某种原因,它总是返回风景。

 UIInterfaceOrientation currentOrientation = (UIInterfaceOrientation)[[UIApplication sharedApplication] statusBarOrientation];
            if (currentOrientation == UIInterfaceOrientationPortrait){
                self.scrollView_.colMargin = 50;
            } else {
                self.scrollView_.colMargin = 130;
            }

知道为什么吗?

最佳答案

您可以按照以下方式检查方向:

UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
    if( orientation == UIDeviceOrientationPortrait ) ...

08-27 19:17