问题描述:

I am adding an image which is in my Resource folder where image name is coming from a xml file.

Xml parsing is returning the name of image correctly as its showing on console.

Now setting this image using,

UIImageView Images=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];

Images.image=[UIImage imageNamed:[myEngine.CountryImageArr objectAtIndex:0]];

[self.view addSubview:Images];

Here [myEngine.CountryImageArr objectAtIndex:0] is giving correct image name and hardcoding that name show the image on imageview. But at run time as shown in code it can not show the image on UIImageView.

I also used [UIImage imagewithContentOfFile:] but it also doesnot solve the problem.

网友答案:

Please make sure that the image name is having correct extensions and all. Also try

UIImageView Images=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
UIImage *img = [UIImage  imageNamed:[myEngine.CountryImageArr objectAtIndex:0]];
[Images setImage:img];
img = nil;
[self.view addSubview:Images];
相关阅读:
Top