IOS8之后系統(tǒng)定位需要許可
在info.plist文件添加 NSLocationWhenInUseUsageDescription 和 NSLocationAlwaysUsageDescription。
代碼添加定位請求
//必須定義全局變量,否則請求提示一閃即逝
CLLocationManager *locationManager;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
locationManager = [[CLLocationManager alloc]init];
if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
[locationManager requestWhenInUseAuthorization];//iOS 8才有荞怒,且必須用上
}
}