gpt4 book ai didi

ios - 用户界面图像 :imageNamed on ipad fails ok in simulator

转载 作者:行者123 更新时间:2023-11-28 20:29:41 25 4
gpt4 key购买 nike

以下代码片段在 iPad 模拟器和 iphone 模拟器上运行良好。然而,当我在我的 ipad 2 上运行它(使用 iphone 模式)时,UIImage 是 nil(调试时检查)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"flowerCell"];

switch (indexPath.section) {
case kRedSection:
cell.textLabel.text=[self.redFlowers objectAtIndex:indexPath.row];
break;

case kBlueSection:
cell.textLabel.text=[self.blueFlowers objectAtIndex:indexPath.row];
break;

default:
cell.textLabel.text=nil;
}

NSString *img=[[NSString alloc] initWithFormat:@"%@%@", cell.textLabel.text, @".png"];

UIImage *flowerImage=[UIImage imageNamed:img];

cell.imageView.image=flowerImage;

return cell;
}

这是从教程书中摘录的 billy basic iphone 示例,这是第一次出现此问题。

最佳答案

尝试完全匹配图像名称小写-大写

如果图像名称是“image.png”并且您在代码中写了名称@“image.PNG”,这将在模拟器上正常工作,但不会在设备上工作

关于ios - 用户界面图像 :imageNamed on ipad fails ok in simulator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12710561/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com