4

可能重复:
如何使用 iphone 计算我们汽车的速度

如何用 iPhone 计算我的速度?例如,我可能想在驾驶时测量汽车的速度。我该如何实施?

4

2 回答 2

11

尝试这样的事情:

- (id) init
{
    self = [super init];
    if (self != nil) {
        self.manager = [[CLLocationManager alloc] init];
        self.manager.delegate = self;
        [self.manager startUpdatingLocation];
    }
    return self;
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
    NSLog(@"Speed = %f", newLocation.speed);
}
于 2012-05-12T20:11:52.337 回答
1

1>您可以使用 GPS 使用定位服务获取特定时间点的经纬度,并且在一定时间段后您可以得到相同的时间说 t。您可以从经纬度和划分中获取经过的距离它被用来获得速度

请参阅 Apple GPS 文档

2>如果您从停止开始,您可以使用加速度计,您应该能够根据设备随时间的加速度计算您行进的距离。

请参阅 Apple Accelerometer 文档

于 2012-05-12T19:25:28.813 回答