unable to load a UIImage in a UIImageView

2019-08-17 04:20发布

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条回答
SAY GOODBYE
2楼-- · 2019-08-17 04:59

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;
查看更多
登录 后发表回答