计算在IOS 7速度之前的iOS 7 I用于计算速度,如下如何使用coreLocation框架
-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
double speed = newLocation.speed;
NSLog(@"Speed of Device is %f",newLocation.speed);
// manual method
if(oldLocation != nil)
{
CLLocationDistance distanceChange = [newLocation getDistanceFrom:oldLocation];
NSTimeInterval sinceLastUpdate = [newLocation.timestamp
timeIntervalSinceDate:oldLocation.timestamp];
double calculatedSpeed = distanceChange/sinceLastUpdate;
NSLog(@"Speed of Device is %f",calculatedSpeed);
}
}
,因为这种方法已被弃用。请给我建议另一种使用CoreLocation使用iOS7来计算速度的方法。
该文档本身告诉你使用什么方法。从苹果文档:告诉委托人有新的位置值可用。 (在iOS 6.0中不赞成使用locationManager:didUpdateLocations:) –