小编Waa*_*han的帖子

将图像保存到自定义库

我有一个应用程序将图像存储到iphone中相册中的自定义库.

我调用了ALAssetLibrary的以下函数

-(void)saveImage:(UIImage*)image toAlbum:(NSString*)albumName withCompletionBlock:(SaveImageCompletion)completionBlock
{
    //write the image data to the assets library (camera roll)
    [self writeImageToSavedPhotosAlbum:image.CGImage orientation:(ALAssetOrientation)image.imageOrientation 
                        completionBlock:^(NSURL* assetURL, NSError* error) {

                          //error handling
                          if (error!=nil) {
                              completionBlock(error);
                              return;
                          }

                          //add the asset to the custom photo album
                          [self addAssetURL: assetURL 
                                    toAlbum:albumName 
                        withCompletionBlock:completionBlock];

                      }];
}
Run Code Online (Sandbox Code Playgroud)

在我的SaveImage IBAction中

-(IBAction)saveToLib:(id)sender
{
    UIImage *savedImage = imgPicture.image;
    NSLog(@"Saved Image%@",savedImage);
    [self.library saveImage:savedImage toAlbum:@"Touch Code" withCompletionBlock:^(NSError *error) {
        if (error!=nil) {
            NSLog(@"Big error: %@", [error description]);
        }
    }];
}
Run Code Online (Sandbox Code Playgroud)

但我的应用程序不断崩溃帮我解决,谢谢你提前

iphone objective-c alassetslibrary

5
推荐指数
1
解决办法
2809
查看次数

标签 统计

alassetslibrary ×1

iphone ×1

objective-c ×1