如何将图像保存到沙箱 - iPhone SDK [英] How do I save an image to the sandbox - iPhone SDK
本文介绍了如何将图像保存到沙箱 - iPhone SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从UIImagePicker中删除了一个图像,我想暂时将它保存到沙箱环境中,在文档文件夹或其他类似的等效文件中。但是,我不知道该怎么做,请有人帮帮我吗?谢谢
I have pulled an image out of the UIImagePicker thingy, and I would like to temporarily save it to the sandbox environment, in either the documents folder, or some other similar equivalent. However, I do not know how to do this, please could someone help me? Thanks
目前图片是UIImage
At the moment the image is a UIImage
推荐答案
正在保存图像:
-(void)saveImage:(UIImage*)image{
NSString *imagePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/someImageName.png"];
[UIImagePNGRepresentation(image) writeToFile:imagePath atomically:YES];
}
加载图片
-(UIImage)loadImage{
NSString *imagePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/someImageName.png"];
UIImage *image = [UIImage imageWithContentsOfFile:imagePath];
}
这篇关于如何将图像保存到沙箱 - iPhone SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文