美文网首页
存储图片到相册

存储图片到相册

作者: X_code_ZH | 来源:发表于2018-06-22 14:12 被阅读0次

使用UIImageWriteToSavedPhotosAlbum函数将图片保存到相册,如:

  • (void)loadImageFinished:(UIImage *)image {
    UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), (__bridge void *)self);
    }
  • (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
    {
    NSLog(@"image = %@, error = %@, contextInfo = %@", image, error, contextInfo);
    }

第一个参数是要保存到相册的图片对象

第二个参数是保存完成后回调的目标对象

第三个参数就是保存完成后回调到目标对象的哪个方法中,方法的声明要如代码中所示的:

  • (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo;
    第四个参数在保存完成后,会原封不动地传回到回调方法的contextInfo参数中。

相关文章

网友评论

      本文标题:存储图片到相册

      本文链接:https://www.haomeiwen.com/subject/wzekyftx.html