将突破保存到本地相册

来源:互联网 发布:mac 虚拟机 win10 4g 编辑:程序博客网 时间:2024/06/06 03:49
点击按钮,将self.imageView上面的image内容保存到本地相册,并指定判断保存成功与否的方法imageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:

- (IBAction)saveImageToAlbum:(id)sender {
    
UIImageWriteToSavedPhotosAlbum(self.imageView.imageself@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);
}


0 0
原创粉丝点击