是否可以在ios8中使用didUpdateToLocation

是否可以在ios8中使用didUpdateToLocation,ios,xcode,ios8,Ios,Xcode,Ios8,可以使用吗 -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation: (CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 在ios8中 它在ios8中被弃用。但是,我使用相同的方法来获取更新的位置 请告知。是的,我们可以查看下面的代码片段 #定义为8或更高版本([[[UIDevice currentDevice]systemVer

可以使用吗

-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:
(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
在ios8中

它在ios8中被弃用。但是,我使用相同的方法来获取更新的位置


请告知。

是的,我们可以查看下面的代码片段

#定义为8或更高版本([[[UIDevice currentDevice]systemVersion]floatValue]>=8.0)

//在ViewDidLoad中

如果(是8或更晚){[self.locationManager 请求始终授权];}

[self.locationManager startUpdatingLocation]

并尽可能在图像中更改info.plist文件


可以使用不推荐使用的方法,但应使用:

-(无效)locationManager:(CLLocationManager*)manager
didUpdateLocations:(NSArray*)位置

要计算速度:

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
    CLLocation *loc = locations.lastObject;
    double speed = loc.speed;
    NSLog(@"%f", speed);
}

但即使设备不运行,速度也在不断提高。您能告诉我如何计算我在设备中测试的速度吗。速度是负的,就连我也这么做了。但我的问题是:即使设备不运行,速度也在不断提高。