在ios中的imageView中显示路径中的图像 [英] Display image from path in imageView in ios

查看:34
本文介绍了在ios中的imageView中显示路径中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有图片路径,我想在 uiimageview 中显示它,

I have image path and I want to display it in uiimageview,

/Users/WTS-New/Library/Developer/CoreSimulator/Devices/F43C‌ 26D2-DCFF-4764-AAF0-‌ F6CC7BCDCF5D/data/Co‌ ntainers/Data/Applic‌ ation/8E49D340-7CAC-‌4031-85BF-9E5C26A1E3‌ 7A/Documents/Small-m‌ ario.png

/Users/WTS-New/Library/Developer/CoreSimulator/Devices/F43C‌​26D2-DCFF-4764-AAF0-‌​F6CC7BCDCF5D/data/Co‌​ntainers/Data/Applic‌​ation/8E49D340-7CAC-‌​4031-85BF-9E5C26A1E3‌​7A/Documents/Small-m‌​ario.png

如何显示图片?

推荐答案

尝试使用以下代码:

从图片名称获取图片路径:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *imageFilePath;
NSError *err;

imageFilePath = [documentsDirectory stringByAppendingPathComponent:@"Small-m‌​ario.png"];

使用 imageWithContentsOfFile 方法设置图像:

YourImageView.image = [UIImage imageWithContentsOfFile: imageFilePath]; 

这篇关于在ios中的imageView中显示路径中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆