2012-05-12 78 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