CGImageRead_mapData'打开'失败...错误= 2(没有这样的文件或目录)

时间:2011-05-24 21:05:45

标签: iphone ios4 uiimage javax.imageio

我已经使用自定义标签栏实现了一个iPhone应用程序。用于选定/未选定选项卡的图像通过UIImage imageNamed加载。通常它工作得很好,但有时,似乎是随机的,其中一个图像在加载并用黑色空白空间替换时消失。再次单击时,图像会重新出现。

一些症状: - 只能在带有4.3的iPhone 4上重现。从未发生在4.2(我已经测试了4.3)。 - 无法使用4.3测试3GS(较低分辨率)。在4.2上它与上面相同,它从未发生过。

我设法从其中一次发生打印,它给了我这里和标题中指定的错误:

ImageIO:CGImageRead_mapData'open' failed'/ var / mobile / Applications / 7A76BCE5-'          error = 2(没有这样的文件或目录)

所有标签图像的启动方式如下:

UIImageView *tab1ImageViewTemp = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, width, height)];

[tab1ImageViewTemp setImage:[UIImage imageNamed:@"bt_tab1"]];//imagem tab1
[self setTab1ImageView:tab1ImageViewTemp];
[self addSubview:tab1ImageView];
[tab1ImageViewTemp release];

当选择/未选中时改变如下:

[tab1ImageView setImage:[UIImage imageNamed:@"bt_tab1_over"]]; //when selected

[tab1ImageView setImage:[UIImage imageNamed:@"bt_tab1"]]; //when unselect

并且在dealloc中正常发布UIImageView。

有人对这个错误有所了解......?

1 个答案:

答案 0 :(得分:0)

(在评论中回答。转换为社区wiki答案。见Question with no answers, but issue solved in the comments (or extended in chat)

@TheBlack写道:

  

你有两种分辨率的图像,一种用于视网膜,一种用于低分辨率屏幕?此外,是否有可能在很短的时间内多次触发选择/取消选择?无论如何,使用名为imageWithContentsOfFile的图像加载图像一次,并将UIImages保存到实例变量。

OP写道:

  

好的,上面的解决方案似乎解决了这个问题。然而,它并没有解释为什么会发生这种情况。我的猜测是因为内存不足。还有其他线索吗?现在更多是因为好奇心。

相关问题