2012-09-05 20 views
0

我的应用程序在iOS 5上运行良好,我得到了普通用户的位置信息。但在iOS 6上安装我的应用程序时,我的应用程序无法获取用户的位置(我没有弹出询问权限的位置,在位置服务中我没有我的应用程序的图标。其他应用程序,如InstagramPath在iOS 6上的位置服务中有应用程序的图标)。当我使用下面的代码来检查这个问题时,NSlog显示:Unable to determine, possibly not available在ios 6上通过我的应用程序获取当前用户的位置有问题

我不明白为什么会出现这种情况。我尝试过其他应用,例如Instagram或Path。我们仍然可以获得正常用户的位置。我在CLLocationManagerDelegate中研究了iOS 6更改方法委托,但我认为这不是原因,因为我的应用程序没有要求获取用户位置的权限。

if ([CLLocationManager locationServicesEnabled]) { 
     NSLog(@"Location Services Enabled"); 
     switch ([CLLocationManager authorizationStatus]) { 
      case kCLAuthorizationStatusAuthorized: 
       NSLog(@"We have access to location services"); 
       break; 
      case kCLAuthorizationStatusDenied: 
       NSLog(@"Location services denied by user"); 
       break; 
      case kCLAuthorizationStatusRestricted: 
       NSLog(@"Parental controls restrict location services"); 
       break; 
      case kCLAuthorizationStatusNotDetermined: 
       NSLog(@"Unable to determine, possibly not available"); 
       break; 
      default: 
       break; 
     } 
    } 
    else { 
     NSLog(@"Location Services Are Disabled"); 
    } 
+0

任何人的帮助,我迫切需要解决这个问题。 非常感谢你 – user1186747

+0

也许我的应用程序与ios6有冲突? – user1186747

回答

0

我认为你的问题是,你只是检查位置是否可用,但不使用它。所以iOS从不要求权限,因为它没有被使用。 您的支票工作正常!

使用像this one这样的教程,它会工作。我也是为我解决它!

1

我有同样的问题。对于我的应用程序产生这种情况,因为我检查是否启用locationServices,我开始更新位置仅如果这是真的([self.locationManager startUpdatingLocation]。)

+ (BOOL)locationServicesEnabled { 
    if (([CLLocationManager locationServicesEnabled]) && ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized)) { 
     return YES; 
    } else { 
     return NO; 
    } 
} 

[self.locationManager startUpdatingLocation]没有检查一下没问题,但可能会产生其他问题。

相关问题