【问题标题】:iPhone - CLHeading to find directioniPhone - CLHeading 寻找方向
【发布时间】:2011-05-16 19:29:46
【问题描述】:

在我的 iPhone 应用程序中,我使用 CLLocationManager 来查找我的 iphone 指向的方向。我正在使用属性“标题”。它给了我 x、y 和 z 值。 如何从这些值中找到我当前指向的方向(北或南或东或西)?

【问题讨论】:

    标签: iphone direction


    【解决方案1】:

    您应该使用方法[locationManager startUpdateHeading] 来启用相对于地理北极或磁北极的角度。然后你就可以得到值了

     - (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading 
    {
       NSLog(@"%f",newHeading.trueHeading);
    }
    

    【讨论】:

      【解决方案2】:

      heading 是一个 CLHeading 对象。一看文档就会告诉您,它还具有以度为单位的真航向和磁航向的属性。

      【讨论】:

      • 感谢您的信息。但是当我使用以下代码并尝试打印该值时,它总是一直打印 -1.00。
      • - (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading { CLLocationDirection dir = [newHeading trueHeading];
      • 如何打印结果?
      猜你喜欢
      • 1970-01-01
      • 2011-07-15
      • 2023-03-15
      • 2018-05-16
      • 1970-01-01
      • 2014-06-04
      • 2016-02-24
      • 2012-04-22
      • 1970-01-01
      相关资源
      最近更新 更多