在UIIMageView上设置图像,其中图像名称来自xml

在UIIMageView上设置图像,其中图像名称来自xml,xml,uiimageview,uiimage,Xml,Uiimageview,Uiimage,我正在添加一个图像,该图像位于我的资源文件夹中,图像名称来自xml文件。 Xml解析将返回正确的图像名称作为其在控制台上的显示。 现在使用 UIImageView Images=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)]; Images.image=[UIImage imageNamed:[myEngine.CountryImageArr objectAtIndex:0]]; [self.view addSubvie

我正在添加一个图像,该图像位于我的资源文件夹中,图像名称来自xml文件。
Xml解析将返回正确的图像名称作为其在控制台上的显示。
现在使用

UIImageView Images=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
Images.image=[UIImage imageNamed:[myEngine.CountryImageArr objectAtIndex:0]];
[self.view addSubview:Images];
此处[myEngine.CountryImageArr objectAtIndex:0]给出了正确的图像名称,并对该名称进行了硬编码,以在imageview上显示图像。但在运行时,如代码所示,它无法在UIImageView上显示图像


我还使用了[UIImage imagewithContentOfFile:],但它也不能解决问题

请确保图像名称具有正确的扩展名和所有名称。 也尝试


我检查了所有这些问题,它们都是正确的。问题是,如果我尝试打印[myEngine.CountryImageArr objectAtIndex:0],它会给出“something.png”,但是当我从这个字符串生成一个UIImage时,比如[UIImage ImageName:[myEngine.CountryImageArr objectAtIndex:0]],它会给出null image.NSString*str=[myEngine.CountryImageArr objectAtIndex:0];UIImageView图像=[[UIImageView alloc]initWithFrame:CGRectMake(0,0320480)];UIImage*img=[UIImage ImageName:str];[图像集图像:img];img=零;[self.view addSubview:Images];
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];