【问题标题】:kCLAuthorizationStatusNotDetermined occurred when tested with iOS 6.1 simulator使用 iOS 6.1 模拟器测试时发生 kCLAuthorizationStatusNotDetermined
【发布时间】:2013-09-19 18:13:15
【问题描述】:

全部。

最近我遇到了这个错误。这是我的代码

if([CLLocationManager locationServicesEnabled]){

    NSLog(@"Location Services Enabled");

    // Switch through the possible location
    // authorization states
    switch([CLLocationManager authorizationStatus]){
        case kCLAuthorizationStatusAuthorized:
            NSLog(@"We have access to location services");
            [self loadAnnotations];
            MKCoordinateSpan span = MKCoordinateSpanMake(0.04, 0.04);
            MKCoordinateRegion region = MKCoordinateRegionMake(locationManager.location.coordinate, span);
            [_mapView setRegion:region animated:YES];
            break;
        case kCLAuthorizationStatusDenied:
            NSLog(@"Location services denied by user");
            [self loadAnnotations];
            [_mapView setRegion:adjustedRegion animated:YES];
            break;
        case kCLAuthorizationStatusRestricted:
            NSLog(@"Parental controls restrict location services");
            [self loadAnnotations];
            [_mapView setRegion:adjustedRegion animated:YES];
            break;
        case kCLAuthorizationStatusNotDetermined:
            NSLog(@"Unable to determine, possibly not available");
            [_mapView setRegion:adjustedRegion animated:YES];
            [self repeatCheckLocation];
    }
}
else{
    // locationServicesEnabled was set to NO
    NSLog(@"Location Services Are Disabled");
    [self loadAnnotations];
    [_mapView setRegion:adjustedRegion animated:YES];
}

这是一个定位应用程序,它调用用户周围的一些地方。它适用于除 6.1 之外的其他版本。每当我在 iOS 6.1 模拟器上运行我的代码时,我都会看到它在 kCLAuthorizationStatusNotDetermined 处停止。奇怪的是..它在我的测试设备上运行时工作,该设备是安装了 iOS 6.1 的 iphone4。我不知道什么时候出错.. 任何帮助将不胜感激

【问题讨论】:

    标签: objective-c xcode mapkit


    【解决方案1】:

    这可能是一个老问题,但其他人可能会觉得它很有用:

    模拟器无法将当前位置作为您的 计算机没有内置 GPS(即使你有,Xcode 也不会使用 它)。但是,模拟器允许您伪造它。

    ......

    默认情况下,模拟器不知道自己的位置。在菜单中 栏,选择“调试”->“位置”。默认位置设置为 “没有任何”。现在将位置设置更改为“Apple”(或“Apple Stores”)。

    检查here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-14
      • 2017-03-07
      • 2014-07-24
      • 2016-01-05
      • 1970-01-01
      • 2014-12-25
      • 2014-09-20
      相关资源
      最近更新 更多