Objective-C - Adding GPS information to a photogra

2019-09-17 06:16发布

问题:

I am wondering if it is possible to add GPS information to a photograph when saving the item to the camera roll.

The code I currently use to save the image is:

UIImage *theImage = (UIImage *)[info objectForKey: UIImagePickerControllerOriginalImage];
        UIImageWriteToSavedPhotosAlbum(theImage, self, 
                                       @selector(image:didFinishSavingWithError:contextInfo:), nil);

I am wondering how I can modify the image EXIF data to add the current location, and make it compatible with the 'Places' functionality on the iPhone.

回答1:

This example: http://caffeinatedcocoa.com/blog/?p=7 explains how to update the date of a photo. Go to CGImageProperties Reference and do the same replacing the key kCGImagePropertyExifDateTimeDigitized of the example with the relevant GPS keys. I haven't try this myself, but sounds like it should work. :)