//Get image corresponding to row index from array
Visitors *tmp = [allItems objectAtIndex:[indexPath row]];
//This works perfectly
[[cell textLabel] setText:[tmp fName]];
[[cell detailTextLabel] setText:[tmp flagName]];
NSString *pathToImage = [tmp flagName];
//This prints correct image file name, like usflag.gif
NSLog(@"%@ ",pathToImage);
//This shows images in each cell
cell.imageView.image =[UIImage imageNamed:@"usflag.gif"];
//This shows nothing
cell.imageView.image =[UIImage imageNamed:pathToImage];
有人可以解释为什么它无法读取图像以及使其正常工作的正确方法。
谢谢。
答案 0 :(得分:0)
您的错误很可能与您的图片名称有关。如果在应用程序包中找到同名图像文件,imageNamed
将仅返回图像。如果存在这些图像文件,请检查每一个。小心拼写。