您的位置:首页 > 其它

文件存储

2016-10-25 15:28 162 查看
<span style="font-size:24px;">UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();  
      
    // 保存图片到指定的路径  
    NSData *data = UIImagePNGRepresentation(newImage);  
    [data writeToFile:@"/Users/userName/Desktop/myShaoNv.png" atomically:YES];  
    </span>  

[objc]
view plain
copy
print?





<span style="font-size:24px;"> // 保存image 到相册中  
    UIImageWriteToSavedPhotosAlbum(newImage, self, @selector(imageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:), nil);  
      
  
// 保存到相册的代理方法, 判断保存的结果是否成功还是失败的信息  
// 实现imageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:  
- (void)imageSavedToPhotosAlbum:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(voidvoid *)contextInfo  
{  
    NSString *message = @"保存照片";  
    if (!error) {  
        message = @"保存成功";  
          
    } else  
    {  
        message = [error description];  
    }  
    NSLog(@"message is %@", message);  
}  
</span> 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: