在工程文件xxx-info.plist里添加两个字段
NSLocationWhenInUseUsageDescription String yes //当你打开app时使用,定位服务
NSLocationAlwaysUsageDescription String yes//一直使用定位服务,不论是否打开
if([[UIDevice currentDevice].systemVersion floatValue] > 8)
{
self.locationManager =[ [CLLocationManager alloc] init];
[self.locationManager requestAlwaysAuthorization];
[self.locationManager requestWhenInUseAuthorization];
}
locationManager必须是全局变量,当为局部变量是手动定位提示AlertView会一闪而过。