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

标签 ios xcode cocoa-touch ipad ios-simulator

以下代码片段在 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/

相关文章:

Swift CollectionViewCells 问题

iPhone/iPad 键盘快捷键?

ios - 从 FCM 向 iOS 设备发送 2-layer-json-payload 时出现问题

ios - Admob Native Advanced 不可点击

ios - XMPPFramework-TURNSocket无法接收到我自己发送的数据吗?

iOS 编程方式的宽高比约束在 UITableviewcell 中被打破

iphone - UITableViewCell Selectioncolor 隐藏所有内容

mysql - 计算两个纬度/经度点之间的距离不一致

ios - 将 DJI 视频源与 Vision Framework 一起使用

ios - 新站推送和执行代码