在iOS中加载保存的图像 [英] Load a Saved Image in iOS
本文介绍了在iOS中加载保存的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我卡住的是我如何使用该保存图像..
我使用下面的代码。它的工作是在文档文件夹中创建一个Test.jpg。
但真的不知道如何访问这个Test.jpg。
pre $ N $ C $ jpgPath = [NSHomeDirectory()stringByAppendingPathComponent :@ 文档/ test.jpg放在];
[UIImageJPEGRepresentation(selectedImage.image,1.0)writeToFile:jpgPath atomically:YES];
NSError *错误;
NSFileManager * fileMgr = [NSFileManager defaultManager];
NSString * documentsDirectory = [NSHomeDirectory()stringByAppendingPathComponent:@Documents];
解决方案
使用这个方法:
imageNamed
在应用程序的主包中查找具有指定名称的图像。
What I am doing is to save an image loaded from any source,(camera / library) and saving it to filesystem in iOS. What I m stuck is at how I can use that save image.. I m using the following code. Its working it is creating a Test.jpg in Documents Folder. But Really have no idea how to access this Test.jpg.
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.jpg"];
[UIImageJPEGRepresentation(selectedImage.image, 1.0) writeToFile:jpgPath atomically:YES];
NSError *error;
NSFileManager *fileMgr = [NSFileManager defaultManager];
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
解决方案
Use this method:
let testImage = UIImage(contentsOfFile: filePath)
imageNamed
looks for an image with the specified name in the application’s main bundle.
这篇关于在iOS中加载保存的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文