如何在iOS中使用PHAsset获取图像的纬度和经度?

如何在iOS中使用PHAsset获取图像的纬度和经度?,ios,objective-c,uiimage,nsdictionary,phasset,Ios,Objective C,Uiimage,Nsdictionary,Phasset,我正在尝试从照片库中获取两个日期和时间范围内的图像 我也通过使用下面的代码来获取图像的信息 PHContentEditingInputRequestOptions *options = [[PHContentEditingInputRequestOptions alloc] init]; options.networkAccessAllowed = YES; //download asset metadata from iCloud if needed [a

我正在尝试从照片库中获取两个日期和时间范围内的图像

我也通过使用下面的代码来获取图像的信息

  PHContentEditingInputRequestOptions *options = [[PHContentEditingInputRequestOptions alloc] init];
        options.networkAccessAllowed = YES; //download asset metadata from iCloud if needed

        [asset requestContentEditingInputWithOptions:options completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) {
            CIImage *fullImage = [CIImage imageWithContentsOfURL:contentEditingInput.fullSizeImageURL];

            //NSLog(@"fullImage=%@", fullImage.properties.description);


        }];
但是图像信息以字符串格式提供给我

我试图将其转换为NSDictionary格式(用于get lat和long),但得到的输出为空

如何获得图像的横向和纵向

如果有其他方法获取信息,请帮助我


提前感谢您

如果您已经有了相位集(如您所说,您已经成功地检索到了它们),则无需执行任何其他操作

您需要的是相位集的属性。它基本上是CLLocation的一个实例。您可以像这样使用它:

asset.location.coordinate.longitude

由于您已经成功地获取了
PHFetchResult
,现在您需要对其进行迭代以获取PHAsset对象,然后从中获取位置信息(如果可用)。要以字典形式从相位集获取GPS信息,请添加以下方法:

-(NSMutableDictionary *) getGPSInformationForAsset: (PHAsset *) asset
{
    NSString *longitude = [NSString stringWithFormat:@"%f",asset.location.coordinate.longitude];
    NSString *latitude = [NSString stringWithFormat:@"%f",asset.location.coordinate.latitude];
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic setValue:longitude forKey:@"longitude"];//Perform proper validation here for whatever your requirements are
    [dic setValue:latitude forKey:@"latitude"];
    return dic;
}
现在使用如下方法:

NSMutableDictionary *coordinatesDictionary = [self  getGPSInformationForAsset:asset];
就这样,你在字典里找到了经纬度

NSMutableDictionary *coordinatesDictionary = [self  getGPSInformationForAsset:asset];