2012-05-12 56 views

回答

10

尝试是这样的:

- (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

使用上面的代码 'newLocation.speed',获取速度始终为-1.0。 – iKT

0

1>您可以使用GPS 使用位置服务获取特定时间点的纬度和经度,并且您可以在一定时间后获得相同的t.You可以获得距离纬度和经度,并通过拍摄来获取速度

See the Apple GPS Doc

2>如果你开始可以使用加速度计 从停止,你应该能够计算出你的旅行 的距离根据关把它设备随着时间的推移加速。

See the Apple Accelerometer Doc