问题
I have set up a UITableView that contain cells of images.
I am using Asset Catalog to name the images appropriately as image1.png, image1@2x.png, and image1@3x.png.
I have an NSMutableArray that I initialize with the image names from Asset Catalog, for example like so:
viewDidLoad:
self.LogoArray = [ [NSMutableArray alloc] initWithObjects:@"image1",@"image2", image2", nil];
Then I created a Custom Cell with my own custom image to display in the cell:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// some code here
cell.customImageView.image = [UIImage imageNamed:[self.LogoArray objectAtIndex:indexPath.row] ];
// some code here
}
The problem is when I run this on the different iPhone platforms, the images are really blurry and resolution is bad.
I believe the compiler doesn't know which version of image.png, image@2x.png, or image@3x.png to assign to cell.customImageView.image
based on what iPhone platform it is running on.
Is there another alternative I should be using to allow Xcode to choose the appropriate image file from Asset Catalog to display it correctly on the different iPhone platforms?
This is how my Asset Catalog looks:

The objects in the LogoArray are named appropriately with the correct name from Asset Catalog.
Thanks
回答1:
You don't need to know the name of the file under the Asset Catalog.
In the screenshot you sent, you should just use the names:
self.LogoArray = [[NSArray alloc] initWithObjects:@"barona_logo", @"chase_logo", @"crabhut_logo", nil];
And you should be ok.
来源:https://stackoverflow.com/questions/27564450/how-to-populate-a-uitableviewcell-with-the-correct-resolution-image