使用iOS 6.1模拟器进行测试时发生了kCLAuthorizationStatusNotDetermined [英] kCLAuthorizationStatusNotDetermined occurred when tested with iOS 6.1 simulator

查看:588
本文介绍了使用iOS 6.1模拟器进行测试时发生了kCLAuthorizationStatusNotDetermined的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部.

最近我被这个错误困扰.这是我的密码

Recently I am stuck with this error. Here is my codes

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的测试设备上运行时正常工作.我不知道什么时候错了. 任何帮助将不胜感激

This is for a location app that calls some places around the user. It is working on other versions but 6.1. Whenever I run my codes on iOS 6.1 simulator I see it stops at kCLAuthorizationStatusNotDetermined. The weird thing is.. it works while running on my testing device which is iOS 6.1 installed iphone4. I have no idea what when wrong.. Any help would be greatly appreciated

推荐答案

这可能是一个古老的问题,但其他人可能会发现它很有用:

It may be an old question, but someone else may find it useful:

模拟器无法获取当前位置作为您的 电脑没有内置GPS(即使您有,Xcode也不会使用 它).但是,模拟器允许您伪造它.

There is no way for the Simulator to get the current location as your computer doesn’t have GPS built-in (even you have, Xcode won’t use it). However, the Simulator allows you to fake it.

......

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

By default, the Simulator doesn’t know its own location. In the menu bar, select "Debug" -> "Location". The default location is set to "None". Now change the location setting to "Apple" (or "Apple Stores").

此处中进行检查.

这篇关于使用iOS 6.1模拟器进行测试时发生了kCLAuthorizationStatusNotDetermined的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆