首先要干这些事

下面的方法亲测可用

------------------------------------------------------------

DNLogFUNC

//初始化位置管理对象

_locationManager = [[CLLocationManager alloc] init];

//请求用户授权

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {

[_locationManager requestWhenInUseAuthorization];

}

//指定定位代理类

_locationManager.delegate = self;

_locationManager.distanceFilter = 100;

//开启定位服务

[_locationManager startUpdatingLocation];

#pragma  mark ----  CLLocationManagerDelegate

//定位成功  位置更新回调 的协议方法

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations

{

CLLocation *currentLocation = [locations lastObject];

CLLocationCoordinate2D coor = currentLocation.coordinate;

//维度

DNLog(@"coor.latitude==%f",coor.latitude);

//经度

DNLog(@"coor.longitude==%f",coor.longitude);

//    //地理编码类

//    CLGeocoder *geocoder = [[CLGeocoder alloc] init];

//    //反编码  经纬度点-->地理位置信息

//    [geocoder reverseGeocodeLocation:[locations lastObject] completionHandler:^(NSArray *placemarks, NSError *error) {

//        if (!error) {

//            //取最后一个地址

//            CLPlacemark *placemark = [placemarks lastObject];

//           NSString *cityStr = [NSString stringWithFormat:@"%@",placemark.locality];

////            DNLog(@"cityStr==%@",cityStr);取出定位城市

//            DNLog(@"placemark==%@",placemark.addressDictionary);

//             DNLog(@"placemarks==%@",placemarks);

//

//        }

//    }];

}

最新文章

  1. iOS保存cookie的方法
  2. location.hash的摘抄
  3. Directory的GetFiles方法
  4. ios app 支持 ipv6-only
  5. 你早该这么玩Excel 读书笔记
  6. 分布式发布订阅消息系统 Kafka 架构设计[转]
  7. mysql 的 decimal类型
  8. 使用form的target属性屏蔽url跳
  9. 记录近期小改Apriori至MapReduce上的心得
  10. oracle存储过程的基本语法
  11. EBS各个应用简称
  12. 加载静态界面----,要不要会加载cookie和页面参数
  13. lodash源码分析之去重--uniq方法
  14. HTTP 错误 500.21 - Internal Server Error 处理程序“BlockViewHandler”在其模块列表中有一个错误模块“ManagedPipelineHandler
  15. FFmpeg数据结构AVFrame
  16. 将 Azure VM 迁移到 Azure 中的托管磁盘
  17. 注意JDBC驱动的版本和JDK的版本是否匹配 JDBC连接Mariadb
  18. Tomcat无法访问中文路径的解决办法
  19. 最优比率生成树 POJ 2728 迭代或者二分
  20. hdoj1176 免费馅饼(dp 数塔)

热门文章

  1. i2c_set_clientdata函数【转】
  2. HDU3613 Best Reward —— Manacher算法 / 扩展KMP + 枚举
  3. Centos7.2——自定义系统服务
  4. 以太坊EVM1.0缺陷
  5. servlet的&lt;url-pattern&gt;
  6. 【NOIP2017 DAY1T2】 时间复杂度
  7. 高可用性和PyMongo
  8. bzoj 4260 REBXOR —— Trie树
  9. kubernetes1.13.1部署ingress-nginx-十一
  10. 洛谷 - P5000 - Hillwer编码 - 高精度