0

我在 iOS 14 beta 和位置权限上检查我的应用程序如果我选择允许位置一旦它要使用 Location failedWithError 方法并且错误对象是

Domain=kCLErrorDomain Code=0 "(null)", error.localizedDescription 是操作无法完成。(kCLErrorDomain 错误 0。)

-(void)loadFetchLocationDetails
{
    if (locationManager == nil)
        locationManager = [[CLLocationManager alloc] init];
    
    locationManager.delegate = self;
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    
    if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
        [locationManager requestWhenInUseAuthorization];
    }
    [locationManager startUpdatingLocation];
    [locationManager startMonitoringSignificantLocationChanges];
}


#pragma mark - CLLocationManagerDelegate Method

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations
{

}

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{

}

有人可以帮我解决这个问题。

4

1 回答 1

1

听起来您忘记启用“位置模拟”。

按如下方式启用它:

  • 转到产品
  • 方案
  • 编辑方案
  • 选项
  • 必须选中允许位置模拟,尝试提供默认位置,不要将其设置为“无”

然后重新启动 XCode,问题应该得到解决。

于 2020-07-14T08:19:23.293 回答