我正在使用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];
}
它适用于iOS 5.1模拟器,但不适用于iOS 4.3模拟器,我认为它可能是iOS 5.1之前的真实设备中的问题。为什么不起作用?
答案 0 :(得分:0)
iOS模拟器在iOS 5之前不支持模拟位置。您遇到的问题是模拟器的限制。