Home 将图片保存到本地相册
Post
Cancel

将图片保存到本地相册

1、将图片保存到iPhone本地相册

调用UIImageWriteToSavedPhotosAlbum()函数,传入image,target传self,SEL是保存图片后响应结果选择器。

1
2
3
4
5
6
7
8
/**
     *  将图片保存到iPhone本地相册
     *  UIImage *image            图片对象
     *  id completionTarget       响应方法对象
     *  SEL completionSelector    方法
     *  void *contextInfo
*/
UIImageWriteToSavedPhotosAlbum(_image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);

2、处理响应结果

提示错误成功信息

1
2
3
4
5
6
7
8
9
10
11
12
//响应对象
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{
 
    NSString * msg = nil;

    if (error == nil) {
        msg = @"保存成功";
    }else{
        msg = @"保存失败";
    }  
 
}
This post is licensed under CC BY 4.0 by the author.

锁屏/解锁事件监听的优化

实现模态跳转透明效果