English 中文(简体)
参考资料 在使用UIImageWrite ToSavedPhotosAlbum() 保存图像之后
原标题:Obtain ReferenceURL after saving an image using UIImageWriteToSavedPhotosAlbum()

I want to obtain the referenceURL to the image that I saved into camera roll using UIImageWriteToSavedPhotosAlbum(). iOS 4.1 or above can do it easily by using AssetLibrary.

ALAssetsLibraryWriteImageCompletionBlock completionBlock = ^(NSURL* url, NSError* error) {
    if (error == nil) {
        savedURL = url;
    }
};    
UIImage * originalImage = [info objectForKey:UIImagePickerControllerOriginalImage];
NSMutableDictionary * metadata = (NSMutableDictionary *)[info objectForKey:UIImagePickerControllerMediaMetadata];  
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeImageToSavedPhotosAlbum:originalImage.CGImage
                             metadata:metadata
                      completionBlock:completionBlock];

但是,在早期的Si-Si,为摄像图书馆保存图像的唯一途径是UIImageWrite ToSavedPhotosAlbum(Saved)。 我认为,一种方式是利用ALAssets来审视挽救的形象。 小组等。 这对我来说不是聪明的,它只会帮助4国集团。

Thank you in advance,

Kiyo

问题回答

用于书写 而是:

[library writeImageToSavedPhotosAlbum:[originalImage CGImage] orientation:(ALAssetOrientation)[originalImage imageOrientation] completionBlock:^(NSURL *assetURL, NSError *error){  
    if (error) {  
        NSLog(@"error");  // oops, error !
    } else {  
        NSLog(@"url %@", assetURL);  // assetURL is the url you looking for 
    }  
}];  




相关问题
iOS ALAssetsLibrary and NSFileHandle reading file contents

I want to read the contents of an assets library file in iOS NSFileHandle fileHandleForReadingFromUrl using the asset defaultRepresentation url seems to always return 0x0... I ll keep looking for a ...

ALAssetsLibrary ALAssetsLibraryAccessUserDeniedError

When you first try to access a user s ALAssetsLibrary, the OS will present them with a dialog asking for permission. If they do not allow this, a failureBlock will be called and will always be called ...

MyImagePicker from WWDC 2010 sample code displays nothing

I compiled and ran the MyImagePicker project from the WWDC 2010 sample code on my iPhone 3Gs with iOS 4.2.1, but it just gives me a blank table. Shouldn t it be populating with data from my photo ...

Trying to guess if a ALAssetPropertyLocation is valid

I m using my new super powers to load an image from the AssetLibrary on iOS 4.+ and read the location the picture was taken. Unfortunately, I m not sure the ALAssetPropertyLocation is valid, and ...

Saving Geotag info with photo on iOS4.1

I am having major issues trying to save a photo to camera roll with geotag info on iOS4.1. I am using following ALAssetsLibrary API: - (void)writeImageDataToSavedPhotosAlbum:(NSData *)imageData ...

热门标签