开发者

CGImageRead_mapData 'open' failed ... error = 2 (No such file or directory)

I have implemented an iPhone application with a customized tabbar. The images used for selected/unselected tab are loaded via UIImage imageNamed. Normally it works just fine, but then sometimes, what seems like randomly, one of the images disappears when it is loaded and replaced with a black empty space. When clicking it again, the image reappears.

Some symptoms: - Only been able to reproduce on iPhone 4 with 4.3. Never happened on 4.2 (and I have tested as much as on 4.3). - Have not been able to test on a 3GS (lower resolution) with 4.3. On 4.2 it is the same as above, it never happened.

I managed to get a print from one of the times it happened, it gave me the error as specified here and in the title:

ImageIO: CGImageRead_mapData 'open' failed '/var/mobile/Applications/7A76BCE5-' error = 2 (No such file or directory)

All tab images are initiated like so:

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];

and when selected/unselected changed like so:

[tab1ImageVi开发者_高级运维ew setImage:[UIImage imageNamed:@"bt_tab1_over"]]; //when selected

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

and the UIImageView is released normally in the dealloc.

Someone that has a clue about this error...?


(Answered in the comments. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )

@TheBlack wrote:

Do you have those images in two resolutions, one for retina, one for lower res screens? Also, is there possibility of something triggering select/unselect many times in very short amount of time? Anyway, load images once with either with image named or imageWithContentsOfFile and save UIImages to instance variables.

The OP wrote:

Ok, seems like the solution above solved the problem. However it didn't explain why it happened. My guess is that it is because of low memory. Any other clues? Now more because of curiosity.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜