码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 图片保存到本地相册

时间:2015-03-31 23:56:06      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:

点击按钮,将self.imageView上面的image内容保存到本地相册,并指定判断保存成功与否的方法imageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:

- (IBAction)saveImageToAlbum:(id)sender {
    UIImageWriteToSavedPhotosAlbum(self.imageView.image, self, @selector(imageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:), nil);
}

实现imageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:方法

- (void)imageSavedToPhotosAlbum:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
    NSString *message = @"呵呵";
    if (!error) {
        message = @"成功保存到相册";
    }else
    {
        message = [error description];
    }
    NSLog(@"message is %@",message);
}

这些代码很简单,如果没有错误的话就提示“成功保存到相册”,如果保存失败的话,那么就输出错误信息[error description]。

iOS 图片保存到本地相册

标签:

原文地址:http://www.cnblogs.com/clumsy1006/p/4382406.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!