Reading the GPS data from the image returned by the camera in iOS iphone

后端 未结 9 1294
余生分开走
余生分开走 2020-11-29 21:36

I need to get the GPS coordinates of an image taken with the iOS device\'s camera. I do not care about the Camera Roll images, just the image taken with UIImagePickerControl

9条回答
  •  失恋的感觉
    2020-11-29 22:26

    This is tested on iOS 8 and works for videos so it should work similarly for photos with a few tweaks.

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    
        NSURL *videoUrl = (NSURL *)[info objectForKey:UIImagePickerControllerMediaURL];
        NSString *moviePath = [videoUrl path];
    
        if ( UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath) ) {
    
            ALAssetsLibrary *assetLibrary = [[ALAssetsLibrary alloc] init];
    
            [assetLibrary assetForURL:[info objectForKey:UIImagePickerControllerReferenceURL] resultBlock:^(ALAsset *asset) {
    
                CLLocation *location = [asset valueForProperty:ALAssetPropertyLocation];
                NSLog(@"Location Meta: %@", location);
    
            } failureBlock:^(NSError *error) {
                NSLog(@"Video Date Error: %@", error);
            }];
    
        }
    
    }
    

提交回复
热议问题