【问题标题】:How to get whether iPhone's camera is facing down the earth or facing up the sky如何判断 iPhone 的摄像头是朝下还是朝上
【发布时间】:2015-01-14 10:08:28
【问题描述】:

您好,我需要知道是否有任何方法可以找到 iPhone 的摄像头位置朝下还是朝上。我需要它,因为我正在做一些概念验证。任何想法将不胜感激。提前致谢。

【问题讨论】:

    标签: ios iphone ipad core-location core-motion


    【解决方案1】:
    1. 您可以采用设备方向.. 你有:

      UIDeviceOrientationFaceUp、UIDeviceOrientationFaceDown

      [https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/index.html#//apple_ref/c/tdef/UIDeviceOrientation][1]

      [1]:http://device%20orientation%20values

    2. 您还可以使用手机加速度计获得更精确的 方向..但我认为使用它已经绰绰有余了 UIDeviceOrientation

    【讨论】:

      【解决方案2】:

      您可以使用UIDeviceorientation 属性(一旦您开始生成方向通知):

      [UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
      

      稍后...

      switch ([[UIDevice currentDevice] orientation]) {
          case UIDeviceOrientationFaceDown: 
              // Do things
      }
      

      或者,要获得更精确的通知,您可以使用 Core Motion 并检查 attitude 属性,但这有点复杂。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-05-15
        • 2012-06-28
        • 1970-01-01
        相关资源
        最近更新 更多