无法在 UIImageView 中加载 UIImage [英] unable to load a UIImage in a UIImageView
本文介绍了无法在 UIImageView 中加载 UIImage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 XCode 4.2 开发 iOS 应用
I am developing an iOS app using XCode 4.2
我有一个 UIImage 变量,我试图通过简单地说 imgView=image
I have a UIImage variable and I am trying to load it in a UIImageView by simply saying imgView=image
但我收到一条错误消息:
but I am getting an error saying :
expected identifier or '('
有人可以帮忙吗
谢谢
我尝试了以下代码:
imgView.image=image;
我收到此错误:
Property 'image' not found on object of type 'imgView'
推荐答案
你应该像这样设置 UIImageView 的图像:
You should set the image of an UIImageView like this:
imageView.image = image;
这是一个更详细的例子:
Here is a more detailed example:
UIImage *image = [UIImage imageNamed:"@image.png"]; // Change "image.png" by the name of your image file
UIImageView *imageView = [[UIImageView alloc] initWithFrame:frame]; // frame is a CGRect.
imageView.image = image;
这篇关于无法在 UIImageView 中加载 UIImage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文