iphone - UIViewController 的 UIInterfaceOrientation

标签 iphone objective-c ios ipad

我尝试检查当前呈现的 View Controller 的 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 ) ...

关于iphone - UIViewController 的 UIInterfaceOrientation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11349557/

相关文章:

iphone - 无法正确设置 datePicker 的默认日期,在 iOS 设备上崩溃

ios - 每周日、周五本地通知

ios - iPhone - 沿触摸和拖动路径移动对象

iOS - MyCustomViewController 类型的 ViewController

ios - Jenkins - xcodebuild 连接对等方拒绝拒绝 dtxproxy :XCTestManager_IDEInterface 的 channel 请求

ios - 联盟控制州

iphone - 这两个会生成相同的编译时间吗?

iphone - 自定义 UIButton 的不透明度

iphone - 防止 UITabBar 将渐变应用于其图标图像

ios - 如何以递增顺序在数组中追加字符串