可能重复:
How to calculate speed of our car using iphone如何用iPhone计算我的速度?
我如何计算我的速度与iPhone?例如,我可能想要在开车时测量我的汽车的速度。我怎样才能实现这个?
可能重复:
How to calculate speed of our car using iphone如何用iPhone计算我的速度?
我如何计算我的速度与iPhone?例如,我可能想要在开车时测量我的汽车的速度。我怎样才能实现这个?
尝试是这样的:
- (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);
}
1>您可以使用GPS 使用位置服务获取特定时间点的纬度和经度,并且您可以在一定时间后获得相同的t.You可以获得距离纬度和经度,并通过拍摄来获取速度
2>如果你开始可以使用加速度计 从停止,你应该能够计算出你的旅行 的距离根据关把它设备随着时间的推移加速。
使用上面的代码 'newLocation.speed',获取速度始终为-1.0。 – iKT