Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iPhone iOS如何从相机滚动图像中提取照片元数据和地理标记信息?_Iphone_Objective C_Ios_Photo_Geotagging - Fatal编程技术网

iPhone iOS如何从相机滚动图像中提取照片元数据和地理标记信息?

iPhone iOS如何从相机滚动图像中提取照片元数据和地理标记信息?,iphone,objective-c,ios,photo,geotagging,Iphone,Objective C,Ios,Photo,Geotagging,可能重复: 我正在制作一个照片应用程序,想知道我使用地理标记照片的选项是什么我想显示照片的拍摄位置(类似于照片应用程序)。这可能吗? 另外,我需要知道照片是什么时候拍的。我可以为自己拍摄的照片捕捉这些信息,但是相机的滚动图像呢 是的,这是可能的 您必须使用ALAssetsLibrary才能访问您的相机卷。然后你只需列举你的照片,并询问位置 assetsLibrary = [[ALAssetsLibrary alloc] init]; groups = [NSMutableArray array

可能重复:

我正在制作一个照片应用程序,想知道我使用地理标记照片的选项是什么我想显示照片的拍摄位置(类似于照片应用程序)。这可能吗?

另外,我需要知道照片是什么时候拍的。我可以为自己拍摄的照片捕捉这些信息,但是相机的滚动图像呢

是的,这是可能的

您必须使用
ALAssetsLibrary
才能访问您的相机卷。然后你只需列举你的照片,并询问位置

assetsLibrary = [[ALAssetsLibrary alloc] init];
groups = [NSMutableArray array];

[assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos  usingBlock:^(ALAssetsGroup *group, BOOL *stop)
{
    if (group == nil)
    {
        return;
    }

    [groups addObject:group];

} failureBlock:^(NSError *error)
{
    // Possibly, Location Services are disabled for your application or system-wide. You should notify user to turn Location Services on. With Location Services disabled you can't access media library for security reasons.

}];
这将枚举您的资产组。接下来,选择一个组并枚举其资产

ALAssetGroup *group = [groups objectAtIndex:0];
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop)
 {
     if (result == nil)
     {
         return;
     }

     // Trying to retreive location data from image
     CLLocation *loc = [result valueForProperty:ALAssetPropertyLocation];    
 }];
现在,您的
loc
变量包含照片拍摄地点的位置。在使用之前,您应该对照
ALErrorInvalidProperty
进行检查,因为有些照片可能缺少此数据

您可以指定
ALAssetPropertyDate
以获取照片创建的日期和时间