简体   繁体   English

iOS 6 CLLocationManager最后位置

[英]iOS 6 CLLocationManager last location

So, as of iOS 6, -locationManager:didUpdateToLocation:fromLocation: is deprecated. 因此,从iOS 6开始,不推荐使用-locationManager:didUpdateToLocation:fromLocation:

Apple suggests, instead, using -locationManager:didUpdateLocations: , which provides anywhere from one to a series of recent location changes. 苹果建议改为使用-locationManager:didUpdateLocations:它提供从一个到一系列最近位置更改的任意位置。 However, in the incredibly likely chance it provides a locations array of length 1, there appears to be no way to access the fromLocation:(CLLocation *)oldLocation parameter of old. 但是,如果它提供一个长度为1的locations数组的fromLocation:(CLLocation *)oldLocation ,则似乎无法访问fromLocation:(CLLocation *)oldLocation参数。

Is there a way to get at this information without using deprecated methods? 有没有办法在不使用不推荐使用的方法的情况下获取此信息?

您只需要将一个属性设置为locationManager:didUpdateLocations:返回的值,就可以将其用作fromLocation,然后再次调用该方法,并将其返回的值用作toLocation。

正如rdelmar所说,如果您需要先前的位置,则只需将从locationManager:didUpdateLocations:收到的最后一个位置存储在一个ivar或属性中,如果locationManager:didUpdateLocations:返回一个只有一个值的数组,请获取先前保存的值在您的ivar /属性中,并将其用于您的“旧”位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM