我希望每秒只获取一次位置更新。这个间隔对于我想创建的动画来说非常重要,可以保持逼真的速度。我知道[myLocationManager startUpdatingLocation]将自动轮询“didUpdateToLocations”,但它不是每秒一次。
有没有办法使用NSTimer每秒获取一次我的位置?
谢谢 -jj
答案 0 :(得分:0)
- (void)startUpdatingLocation
self.locationManager = [CLLocationManager new];
self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
self.locationManager.delegate = self;
[self.locationManager startUpdatingLocation];
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateLocation) userInfo:nil repeats:YES];
}
- (void)updateLocation {
CLLocation location = self.locationManager.location;
// do all the work here
}
#pragma mark - CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
// do nothing here
}