unable to load a UIImage in a UIImageView

做~自己de王妃 提交于 2019-12-25 08:19:30

问题


I am developing an iOS app using XCode 4.2

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 '('

can someone please assist

thank you

Edited :

I tried the following code :

imgView.image=image;

I am getting this error :

Property 'image' not found on object  of type 'imgView'

回答1:


You should set the image of an UIImageView like this:

imageView.image = image;

Edit: 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;


来源:https://stackoverflow.com/questions/9369543/unable-to-load-a-uiimage-in-a-uiimageview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!