gpt4 book ai didi

ios - 单点触控 : CLLocationManagerDelegate UpdatedLocation

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:06:12 25 4
gpt4 key购买 nike

CLLocationManagerDelegate 中的 UpdatedLocation 现在已过时。

我如何获得此功能以及在什么新函数调用下?

旧:

        public override void UpdatedLocation (CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation)
{
manager.StopUpdatingLocation ();
locationManager = null;
callback (newLocation);
}

最佳答案

从 iOS 6 开始,您必须重写委托(delegate)中的 LocationsUpdated 方法:

public override void LocationsUpdated (CLLocationManager manager, CLLocation[] locations)
{
// Code
}

locations 参数将始终包含至少一个 CLLocation 对象,最近的位置将是数组中的最后一项:

CLLocation recentLocation = locations[locations.Length - 1];

如果您的应用支持 iOS 5,您可以保留 UpdatedLocation 方法。不需要其他更改,调用 StartUpdatingLocationStopUpdatingLocation 时同样适用。

这在 Apple 关于 CLLocationManagerstartUpdatingLocation 方法的文档中有解释 here .

关于ios - 单点触控 : CLLocationManagerDelegate UpdatedLocation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13262385/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com