是否有ALAssetsLibrary的样本

时间:2010-09-01 12:42:07

标签: ios4

对于iPhone 4,许多API不能再使用了。

我正在为UIImageWriteToSavedPhotosAlbum寻找替代解决方案。

ALAssetsLibrary是Apple在新iOS 4中的最新解决方案。

任何人都有这方面的经验,可以提供一些样本或开源项目吗?

谢谢

1 个答案:

答案 0 :(得分:5)

你需要做这样的事情 -

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
    }] ;

虽然我疯狂地想弄清楚如何使这些代码与iphone 3 SDK保持兼容。