我正在为iOS9准备我的iOS8应用程序。我读到过,CLLocationManager现在有一个名为allowsBackgroundLocationUpdates的成员变量,对于iOS9,需要将其设置为true。但是,Xcode不会将其识别为CLLocationManager的成员。我需要做什么更改才能让Xcode识别该属性?我正在运行Xcode7。
- (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;
}
}
发布于 2015-10-17 01:23:40
此功能(allowsBackgroundLocationUpdates
)仅适用于iOS 9。请注意,它是实例属性,而不是类属性。
只要您链接到iOS 8,您就不必担心它,因为即使您在iOS 9上运行,它也不会影响您。如果您链接到iOS 9,您必须在您持有的每个CLLocationManager实例上设置此属性,否则您的后台位置更新将不会发生。
https://stackoverflow.com/questions/33172332
复制相似问题