打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
[转载]通过GPS信息获取当前所在城市名的代码

    利用 iPhone、iPad 自带的 GPS信息可以获得当前位置坐标,但直接高速用户坐标是不行的。CocoaChina 会员"laigb"分享了通过 GPS信息获取当前所在城市名的代码,希望对苹果开发者有所帮助。

    -(void)startedReverseGeoderWithLatitude:(double)latitudelongitude:(double)longitude{
       CLLocationCoordinate2D coordinate2D;
       coordinate2D.longitude = longitude;
       coordinate2D.latitude = latitude;
       MKReverseGeocoder *geoCoder = [[MKReverseGeocoder alloc]initWithCoordinate:coordinate2D];
       geoCoder.delegate = self;
       [geoCoder start];
    }#pragmamark -
    -(void)reverseGeocoder:(MKReverseGeocoder *)geocoderdidFindPlacemark:(MKPlacemark *)placemark
    {
    //NSString*subthroung=placemark.subThoroughfare;
    NSString*local=placemark.locality;
   //NSLog(@"城市名:%@-%@-%@",placemark.locality,local,subthroung);
       if (local) {
           [cityLabel setText:local];
       }
    }
    -(void)reverseGeocoder:(MKReverseGeocoder *)geocoderdidFailWithError:(NSError *)error
    {
    }

转:http://www.cocoachina.com/iphonedev/sdk/2011/0418/2795.html

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
MapKit学习笔记及源码分享
定位经纬度解析城市信息 CLGeocoder /CLLocationManager
定位-计算距离
基于gps定位给ecshop手机端增加自动城市插件
python读取与保存图片的exif信息
Dive Into HTML5:地理位置
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服