问个GPS 的问题,[CLLocationManager locationServicesEnabled]可以用这个方法来判断GPS有没有开启,但是判断不了GPS有没有授权给这个应用啊。本人的程序判断了手机是有开启GPS,但是有没有给应用授权GPS判断不了(实际是没授权给应用),直接开始 start GPS的定位,结果GPS不返回成功也不返回失败给程序了,定在那了
附上 初始化程序:
附上 初始化程序:
-(void)viewDidLoad{
[super viewDidLoad];
self.locationManager = [[CLLocationManager alloc] init];
// 定位距离
self.locationManager.distanceFilter = kCLLocationAccuracyHundredMeters;
// 定位效果
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
// 设置代理
self.locationManager.delegate = self;
}
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
if ([CLLocationManager locationServicesEnabled]) {
if ([[[UIDevice currentDevice]systemVersion]floatValue]>=8.0 ) {
[self.locationManager requestAlwaysAuthorization];
}
[self.locationManager startUpdatingLocation];
}else{
[_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.URLString]]];
}
}
#program mark - 代理方法这里省略不写 了