gpt4 book ai didi

iphone - CLGeocoder 和向后兼容性

转载 作者:行者123 更新时间:2023-12-03 18:42:04 25 4
gpt4 key购买 nike

我有一个简单的问题。

MKReverseCoder 已弃用,自 iOS 5 起不再工作。我们必须使用CLGeocoder。但是,iOS4下有很多人。新应用程序如何与 iOS4 和 iOS5 一起使用进行地理编码?

谢谢!

最佳答案

如果有人尝试从 MKReverseGeocoder 转移到 CLGeocoder,那么我写了一篇博客文章,可能会有所帮助 http://jonathanfield.me/jons-blog/clgeocoder-example.html

基本上,一个示例是,在创建了 locationManager 和 CLGeocoder 对象后,只需将此代码添加到您的 viewDidLoad() 中,然后制作一些标签或文本区域来显示数据。

[super viewDidLoad]; locationManager.delegate = self; [locationManager startUpdatingLocation];

locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
[self.CLGeocoder reverseGeocodeLocation: locationManager.location completionHandler:
^(NSArray *placemarks, NSError *error) {

CLPlacemark *placemark = [placemarks objectAtIndex:0];

isoCountryCode.text = placemark.ISOcountryCode;
country.text = placemark.country;
postalCode.text= placemark.postalCode;
adminArea.text=placemark.administrativeArea;
subAdminArea.text=placemark.subAdministrativeArea;
locality.text=placemark.locality;
subLocality.text=placemark.subLocality;
thoroughfare.text=placemark.thoroughfare;
subThoroughfare.text=placemark.subThoroughfare;
//region.text=placemark.region;

}];

关于iphone - CLGeocoder 和向后兼容性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7809142/

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