【问题标题】:Detect verticality of iPhone [duplicate]检测iPhone的垂直度[重复]
【发布时间】:2012-07-21 17:02:17
【问题描述】:

可能重复:
Get pitch, roll and yaw relative to geographic north on iOS?

有没有办法检测 iPhone 是垂直的?

陀螺仪为我们提供了相对于位置的绝对角度。

但是我怎么知道这个相对位置是否对应一个垂直位置呢?

【问题讨论】:

    标签: objective-c ios gyroscope core-motion


    【解决方案1】:
    if (UIInterfaceOrientationIsPortrait([[UIDevice currentDevice] orientation])) {
        // device is currently in portrait (vertical) orientation
    }
    

    【讨论】:

    • 正如我在回答中所指出的,请务必阅读课程文档以获取有关确保您获得有效值的信息。
    • 我想做AR应用。为建筑添加一些注释:)
    【解决方案2】:

    如果您不是在寻找精确的角度信息,而只是在宏观方向,请检查 [[UIDevice currentDevice] orientation]

    请务必阅读类文档以了解一些重要的实现细节。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-25
    • 1970-01-01
    • 1970-01-01
    • 2014-04-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-10
    相关资源
    最近更新 更多