1

我每 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 公里/小时时显示警报。

有没有其他方法可以用来找到相同的方法?

谢谢..

4

1 回答 1

3

像这样启动和停止位置管理器不是这样做的方法。您不能强迫它提供更多位置更新。让它运行并随着时间的推移平均位置更新。要获得最佳准确性,请使用kCLLocationAccuracyBestForNavigation位置管理器的desiredAccuracy.

于 2013-08-05T14:35:01.697 回答