[英]CLLocationManager is not working in the iOS 4.3 simulator
I'm using CLLocationManager to determine my current location: 我正在使用CLLocationManager来确定我当前的位置:
- (void)viewDidLoad
{
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
self.currentLocation = newLocation;
NSTimeInterval locationAge = -[newLocation.timestamp timeIntervalSinceNow];
if (locationAge > 5.0) return;
if (newLocation.horizontalAccuracy < 0) return;
if (self.currentLocation == nil || self.currentLocation.horizontalAccuracy > newLocation.horizontalAccuracy) {
self.currentLocation = newLocation;
}
[locationManager stopUpdatingLocation];
}
It works in iOS 5.1 simulator but not in iOS 4.3 simulator, and I think it might be a problem in real devices before iOS 5.1. 它适用于iOS 5.1模拟器,但不适用于iOS 4.3模拟器,我认为它可能是iOS 5.1之前的真实设备中的一个问题。 Why is it not working?
为什么不起作用?
iOS模拟器在iOS 5之前不支持模拟位置。您遇到的问题是模拟器的限制。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.