CLLocationManager在iOS 8 Simulator上不起作用

时间:2015-03-06 13:37:35

标签: ios objective-c cllocationmanager

我有一个非常奇怪的问题。 在我的应用程序中,我使用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];

1 个答案:

答案 0 :(得分:0)

您可能需要设置自定义位置。

进入顶部栏菜单,点击Debug,然后点击Location,然后选择您的选择:)