随着 iOS6 的发布,Apple 希望我们使用 didUpdateLocations 而不是 didUpdateToLocation。谁能解释如何正确使用 didUpdateLocations?
我假设您使用以下代表来获得最后一个位置?
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
上面的委托在 iOS 6 中已被弃用。现在应该使用以下内容:
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray *)locations
为了获得最后一个位置,只需获取数组的最后一个对象:
[locations lastObject]
换句话说,[locations lastObject]
(新代表)等于newLocation
(老代表)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)