ios8地图开发的报错

 

报错如下:Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.

网上一搜大把类似的帖子

 

解决办法:在工程的info.plist文件里面添加两项属性。value值为yes

      NSLocationWhenInUseUsageDescription  

      NSLocationAlwaysUsageDescription 

    

代码里面写:

   

 1 _locationManager=[[CLLocationManager alloc]init];
 2 
 3     if(![CLLocationManager locationServicesEnabled]||[CLLocationManager authorizationStatus]!=kCLAuthorizationStatusAuthorizedWhenInUse){
 4 
 5         [_locationManager requestWhenInUseAuthorization];
 6 
 7     }
 8 
 9     [_locationManager setDelegate:self];
10 
11     [_locationManager requestAlwaysAuthorization];        //NSLocationAlwaysUsageDescription
12 
13     [_locationManager requestWhenInUseAuthorization];     //NSLocationWhenInUseDescription

 

 

 

转载于:https://www.cnblogs.com/Army598719273/p/4904690.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值