iOS开发设置定位提示框的解决方法
2018-01-15 本文已影响0人
浪了里个浪
iOS开发设置定位提示框的解决方法
1.首先查看你的info.plist里面是否添加Privacy - Location Always Usage Description,Privacy - Location When In Use Usage Description.

2.在info.plist里面添加
<key>NSLocationWhenInUseUsageDescription</key>
<string>App需要您的同意,才能在使用期间访问位置</string>

3.代码设置
#pragma mark 定位功能
- (void)locate {
//判断定位功能是否打开
if ([CLLocationManager locationServicesEnabled]) {
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
[locationManager requestAlwaysAuthorization];
[locationManager startUpdatingLocation];
}
}
4.大功告成.

5.如果没有出来的话试试清除下缓存或者在TARGETS--Info--Custom iOS Target Properties查看是否设置了定位服务
