无人能解,至高神何在。iOS 判断GPS有没给应用授权

iOS 码拜 8年前 (2016-01-30) 900次浏览
问个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 - 代理方法这里省略不写 了

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明无人能解,至高神何在。iOS 判断GPS有没给应用授权
喜欢 (0)
[1034331897@qq.com]
分享 (0)