在UIImageView中显示本地图像 [英] Display local image in UIImageView

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

问题描述

如何在硬盘驱动器中显示UIImageView组件中的图像?

How do I display an image in the UIImageView component from the hard drive?

我有一个名为images的本地文件夹,并希望通过相对
路径,因为我想用应用程序打包图像。

I have a local folder called "images" and would like to access it via a relative path, since I want to package the images with the app.

推荐答案

从你的某个地方加载图片开车使用:

To load image from somewhere on your drive use:

UIImage * myImage = [UIImage imageWithContentsOfFile: @"../images/1.png"];

或者将图像添加到Xcode项目并使用:

Or add image to the Xcode project and use:

UIImage * myImage = [UIImage imageNamed: @"1.png"];

之后将图像添加到imageview:

After that add image to imageview:

UIImageView * myImageView = [[UIImageView alloc] initWithImage: myImage];

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

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