Is there any sample for ALAssetsLibrary

2020-07-23 04:59发布

问题:

For iPhone 4 , a lot API can not be used any more.

I am looking for alternative solution for UIImageWriteToSavedPhotosAlbum.

ALAssetsLibrary is current solution from Apple in new iOS 4.

Anyone has experience for that and can give some samples, or open source projects ?

Thanks

回答1:

you need to do something like this -

ALAssetsLibrary* library=[[ALAssetsLibrary alloc] init] ; 
// Request to save the image to camera roll
[library writeImageToSavedPhotosAlbum:img.CGImage orientation:(ALAssetOrientation)img.imageOrientation 
    completionBlock:^(NSURL* assetURL, NSError* error) {
        if (error != NULL)
            // Show error message...
        else  // No errors
            // Show message image successfully saved
    }] ;

Although I'm going crazy trying to figure out how to keep this code compatible with iphone 3 SDK.



标签: ios4