【问题标题】:Saving Image To Custom Library将图像保存到自定义库
【发布时间】:2012-04-19 09:57:29
【问题描述】:

我有一个应用程序,可以将图像存储到 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];

                      }];
}

在我的 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]);
        }
    }];
}

但我的应用程序不断崩溃 帮帮我 提前致谢

【问题讨论】:

  • 关于 NSLog 的声明
  • 发送到实例的无法识别的选择器
  • 请告诉您完整的崩溃日志...
  • *** 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[ALAssetsLibrary saveImage:toAlbum:withCompletionBlock:]: 无法识别的选择器发送到实例 0x8eafb60”

标签: iphone objective-c alassetslibrary


【解决方案1】:

您似乎没有正确调用 [self.library saveImage:savedImage toAlbum:@....]。如果您关注此web site,请在您的视图控制器中添加#import "ALAssetsLibrary+CustomPhotoAlbum.h"。

不确定是否是问题所在。抱歉,如果此解决方法是错误的方法。

【讨论】:

    【解决方案2】:

    问题是他从网站下载的文件。

    我遇到了同样的问题,自己重写代码解决了这个问题。

    可能是编码或类似的东西......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多