【问题标题】:Which function of core location framework gets called when user changes its current location?当用户改变当前位置时,核心位置框架的哪个函数被调用?
【发布时间】:2012-06-05 05:22:31
【问题描述】:

我在我的应用程序中使用核心位置框架我想问当用户更改其当前位置时调用核心位置框架的哪个函数。

【问题讨论】:

    标签: iphone ios5 gps xcode4.2 core-location


    【解决方案1】:

    当有新位置可用时调用此方法。如果没有以前的可用位置,oldLocation 可能为零。

    - (void)locationManager:(CLLocationManager *)manager
            didUpdateToLocation:(CLLocation *)newLocation
            fromLocation:(CLLocation *)oldLocation;
    

    【讨论】:

    • 感谢 Mudit,如何更改 iphone 4s 中的当前位置以测试此功能?我必须通过点击此方法中的特定 url 在服务器上发送更新的位置。
    • 你可以使用newLocation.coordinate.latitude和newLocation.coordinate.longitude.check this在这个函数中获取newLocation的经纬度
    • 当我们从当前位置移动到很远的地方并且应用程序在后台运行时会自动调用这个函数吗?还是我每次都需要将 CLLocation 对象设置为 nil 才能获取 newLocation?
    • 您必须设置 CLLocationManager 的委托属性,然后它会调用并且在后台它也会自动调用。要移动到很远的距离,您必须设置 CLLocationManager 的所需精度属性。然后它将自动更新 newLocation,您将通过 newLocation 获取新坐标。
    • 感谢 Mudit,还有一个问题是我每次都需要将 CLLocation 对象设置为 nil 才能获得 newLocation 吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多