我已经设置了一个包含图像单元格的 UITableView。
我正在使用 Asset Catalog 将图像适当命名为 image1.png、image1@2x.png 和 image1@3x.png。
我有一个 NSMutableArray,我使用 Asset Catalog 中的图像名称进行初始化,例如:
viewDidLoad:
self.LogoArray = [ [NSMutableArray alloc] initWithObjects:@"image1",@"image2", image2", nil];
然后我用我自己的自定义图像创建了一个自定义单元格以显示在单元格中:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// some code here
cell.customImageView.image = [UIImage imageNamed:[self.LogoArray objectAtIndex:indexPath.row] ];
// some code here
}
问题是当我在不同的 iPhone 平台上运行它时,图像真的很模糊而且分辨率很差。
我相信编译器不知道根据什么 iPhone 平台将哪个版本的 image.png、image@2x.png 或 image@3x.png 分配给 cell.customImageView.image
它正在运行。
我应该使用另一种替代方法来允许 Xcode 从 Assets 目录中选择适当的图像文件以在不同的 iPhone 平台上正确显示它吗?
这是我的 Assets 目录的样子:
LogoArray 中的对象使用 Asset Catalog 中的正确名称进行适当命名。
谢谢
最佳答案
您不需要知道 Assets 目录下文件的名称。
在您发送的屏幕截图中,您应该只使用名称:
self.LogoArray = [[NSArray alloc] initWithObjects:@"barona_logo", @"chase_logo", @"crabhut_logo", nil];
你应该没问题。
关于ios - 如何使用正确的分辨率图像填充 UITableViewCell?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27564450/