【问题标题】:Need to resolve issue related to orientation in MonoTouch需要解决与 MonoTouch 中的方向相关的问题
【发布时间】:2012-12-23 09:29:17
【问题描述】:

我想获取设备的当前方向。我在 AppDelegate 类中编写了这段代码: 我的代码:

if (UIInterfaceOrientation.LandscapeLeft == (UIInterfaceOrientation)UIDevice.CurrentDevice.Orientation &&
            UIInterfaceOrientation.LandscapeRight == (UIInterfaceOrientation)UIDevice.CurrentDevice.Orientation) {
            //code
        } else {
            //code
        }

UIDevice.CurrentDevice.Orientation 给出未知数?

【问题讨论】:

  • 请注意,您的上述条件将始终为假,因为Orientation 不能同时 LandscapeLeft 和LandscapeRight。除此之外,更多信息将有助于了解您的问题。

标签: ios6 xamarin.ios c#-3.0 ios-simulator


【解决方案1】:

您可以使用UIViewController 的InterfaceOrientation 属性吗?

这可能是一个更好的检查值,因为它是您的应用当前旋转并“允许”旋转到的状态。检查UIDevice 可能与您的 UI 旋转不匹配。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-31
    • 2014-05-12
    • 1970-01-01
    • 2021-01-03
    • 2011-02-07
    相关资源
    最近更新 更多