我每 0.1 秒后使用以下代码更新位置 -
- (void)viewDidLoad
{
[super viewDidLoad];
CLController = [[CoreLocationController alloc] init];
CLController.delegate = self;
// set auto update timer
currentTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self
selector:@selector(updatestart) userInfo:nil repeats:YES];
}
-(void)updatestart
{
[CLController.locMgr startUpdatingLocation];
}
然后我尝试使用计算速度
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
[locMgr stopUpdatingLocation];
NSLog(@"%f",newLocation.speed);
}
我的速度以米/秒为单位,但一段时间后,这个过程变慢了,即使我停止行驶,速度也在计算中。
我想要的是获得准确的速度并在速度高于 12 公里/小时时显示警报。
有没有其他方法可以用来找到相同的方法?
谢谢..