I\'ve implemented the delegate method and can get access to the picked UIImage, like this:
- (void)imagePickerController:(UIImagePickerController *)picker didFin
You could use the UIImagePickerControllerReferenceURL value of the info dictionary instead of the UIImagePickerControllerOriginalImage. This should give you the URL to the original media item.
This would return you a NSURL object which you then can use to build your new filename from.
Use the code below
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
[library writeImageToSavedPhotosAlbum:image.CGImage orientation:(ALAssetOrientation)image.imageOrientation completionBlock:^(NSURL *assetURL, NSError *error )
{
[library assetForURL:assetURL resultBlock:^(ALAsset *asset )
{
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *imageAsset)
{
ALAssetRepresentation *imageRep = [imageAsset defaultRepresentation];
NSLog(@"reference image filename picking from camera: %@", [imageRep filename]);
};
ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
[assetslibrary assetForURL:assetURL resultBlock:resultblock failureBlock:nil];
}
failureBlock:^(NSError *error )
{
NSLog(@"Error loading asset");
}];
}];
imageView.image = [info objectForKey:UIImagePickerControllerEditedImage];
imageView.contentMode = UIViewContentModeScaleAspectFit;