简体   繁体   English

如何在iOS中使用拍摄的照片保存GPS数据

[英]How to save GPS data with a taken photo in ios

I am developing a camera application which can be used to take pictures and save them in a separate album. 我正在开发一个相机应用程序,可用于拍摄照片并将其保存在单独的相册中。 I used photos framework to save images and now I need to save GPS data (location where the picture is taken) with the picture (may be in metadata). 我使用照片框架保存图像,现在我需要将GPS数据(拍摄照片的位置)与照片(可能在元数据中)一起保存。 I searched for any method to do this thing using photos framework but I failed, I couldn't find anything related. 我搜索了使用照片框架执行此操作的任何方法,但失败了,找不到任何相关内容。 Any help would be highly appreciated. 任何帮助将不胜感激。

This is the peace of code I used to save pictures 这是我用来保存图片的代码的安全性

[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{

    PHAssetChangeRequest *assetRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:capturedImage];

    placeholder = [assetRequest placeholderForCreatedAsset];

    photosAsset = [PHAsset fetchAssetsInAssetCollection:Album options:nil];

    PHAssetCollectionChangeRequest *albumChangeRequest = [PHAssetCollectionChangeRequest changeRequestForAssetCollection:Album                                                assets:photosAsset];

    [albumChangeRequest addAssets:@[placeholder]];

} completionHandler:^(BOOL success, NSError *error) {

    if (success)
    {

    }
    else
    {

    }

}];

I assume you want the latitude & longitude. 我假设您想要纬度和经度。 Have you tried the location property of PHAsset class? 您是否尝试过PHAsset类的location属性?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM