1

我正在为此计算设备的速度,我使用了委托方法

(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation

但是当我在设备上对其进行测试时,它没有显示速度,而是始终显示零速度。

使用的代码是

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{        
    NSLog(@"\nStarting point=%@",startingpoint);
    if (self.startingpoint == nil)
    {
        self.startingpoint = newLocation;
        oldLocation=self.startingpoint;
    }
    //Calculate speed
    double gpsSpeed = newLocation.speed;
}
4

0 回答 0