以下是我初始化我的位置管理器的方法:
if (_locationManager == nil) { NSLog(@"Creating location manager"); _locationManager = [[CLLocationManager alloc] init]; _locationManager.delegate = self; _locationManager.distanceFilter = kCLdistanceFilterNone; _locationManager.desiredAccuracy = kCLLocationAccuracyBest;}if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined) { NSLog(@"Not determined"); if ([[NSUserDefaults standardUserDefaults] boolForKey:@"dynamicNotifOn"]) { [_locationManager requestAlwaysAuthorization]; } else { [_locationManager requestWhenInUseAuthorization]; }} else if (...) {...
这是方法:
- (voID)locationManager:(CLLocationManager *)manager dIDChangeAuthorizationStatus:(CLAuthorizationStatus)status { NSLog(@"Callback"); if (status == kCLAuthorizationStatusAuthorizedAlways || status == kCLAuthorizationStatusAuthorizeDWhenInUse) { NSLog(@"Authorized"); [_mainbutton setIsLoading:NO]; [self startGettingLocation]; } else if (status == kCLAuthorizationStatusDenIEd || status == kCLAuthorizationStatusRestricted) { NSLog(@"DenIEd"); _currentState = CurrentStateError; [_mainbutton setUpbuttonForState:_currentState]; }}
按下初始化位置管理器(顶部代码块)的按钮后,这就是控制台打印出来的内容:
Creating location managerNot determinedCallback
然后我在d出的AlertVIEw中做出选择:
*nothing*解决方法 在我的情况下,问题是在非主线程中. 只需确保在主线程上创建位置管理器. 总结
以上是内存溢出为你收集整理的ios – 更改状态后未调用didChangeAuthorizationStatus全部内容,希望文章能够帮你解决ios – 更改状态后未调用didChangeAuthorizationStatus所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)