【发布时间】:2015-03-06 13:37:34
【问题描述】:
我有一个非常奇怪的问题。
在我的应用程序中,我使用CLLocationManager 读取了实际坐标,但在 iOS 8 模拟器上不起作用。在 iOS 物理设备上一切正常,甚至在 iOS 7 模拟器上。
self.manager = [[CLLocationManager alloc] init];
self.manager.delegate = self;
self.manager.desiredAccuracy = kCLLocationAccuracyBest;
if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))
{
NSUInteger code = [CLLocationManager authorizationStatus];
if (code == kCLAuthorizationStatusNotDetermined &&
([self.manager respondsToSelector:@selector(requestAlwaysAuthorization)] ||
[self.manager respondsToSelector:@selector(requestWhenInUseAuthorization)]))
{
if(Get_Plist_Object(@"NSLocationAlwaysUsageDescription"))
{
[self.manager requestAlwaysAuthorization];
}
else if(Get_Plist_Object(@"NSLocationWhenInUseUsageDescription"))
{
[self.manager requestWhenInUseAuthorization];
}
else
{
NSLog(@"Info.plist does not contain NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription");
}
}
}
[self.manager startUpdatingLocation];
【问题讨论】:
-
尝试为模拟器设置自定义位置 Debug > Location > Custom,或者甚至首先尝试将其设置为默认值之一,例如 Apple。
-
我在当前位置设置了自定义位置。更改并设置Apple后,它可以工作。很奇怪....这是一个错误?
-
我认为这与模拟器总是将自定义位置重置为 none(0,0) 有关这是一个关于它的主题stackoverflow.com/questions/22643779/… 我不能告诉你确切的原因,我不知道它。
-
iOS 8 模拟器似乎在每次启动时都会清除位置,或者更随机。我认为这是非常错误的。 Xcode 5.X 模拟器没有这个问题。每次在需要的地方运行时,我都必须手动重新选择位置。
标签: ios objective-c cllocationmanager