繁体   English   中英

CLLocationManager在iOS 8 Simulator上不起作用

[英]CLLocationManager doesn't work on iOS 8 Simulator

我有一个非常奇怪的问题。 在我的应用程序中,我使用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 ,然后选择你的选择:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM