CLLocationManager没有allowBackgroundLocationUpdates成员变量

时间:2015-10-16 13:59:01

标签: cordova ios8 ios9 cllocationmanager

我正在使用我的iOS8应用程序并为iOS9做好准备。我已经读过CLLocationManager现在有一个名为allowsBackgroundLocationUpdates的成员变量,需要为iOS9设置为true。但是,Xcode不会将其识别为CLLocationManager的成员。我需要更改什么才能让Xcode识别该属性?我正在运行Xcode 7。

    - (BOOL)isLocationServicesEnabled
    {
        BOOL locationServicesEnabledInstancePropertyAvailable = [self.locationManager respondsToSelector:@selector(locationServicesEnabled)]; // iOS 3.x
        BOOL locationServicesEnabledClassPropertyAvailable = [CLLocationManager respondsToSelector:@selector(locationServicesEnabled)]; // iOS 4.x

        if (locationServicesEnabledClassPropertyAvailable) { // iOS 4.x
            return [CLLocationManager locationServicesEnabled];
         } else if (locationServicesEnabledInstancePropertyAvailable) { // iOS 2.x, iOS 3.x
            return [CLLocationManager locationServicesEnabled];
        } else {
            return NO;
        }
    }

1 个答案:

答案 0 :(得分:0)

此功能(allowsBackgroundLocationUpdates)仅适用于iOS 9。请注意,它是实例属性,而不是类属性。

只要您连接iOS 8就不必担心,因为即使您在iOS 9上运行它也不会影响您。如果您要连接iOS 9,则必须设置此属性您持有的每个CLLocationManager实例,或者您的后台位置更新都不会发生。

https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/#//apple_ref/occ/instp/CLLocationManager/allowsBackgroundLocationUpdates

相关问题