开发者

Problem with NSMutableArray arrayWithObjects:

NSMutableArray *images = [NSMutableArray arrayWithObjects:[UIImage imageNamed:@"JGirl 01.jpg"],
    [UIImage imageNamed:@"JGirl 03.jpg"], ... ,
    [UIImage imageNamed:@"JGirl 48.jpg"],
    nil];

self.vi开发者_运维问答ew = [[[SlideShowView alloc] initWithImages:images byIndex:index] autorelease];

assume that my images contain 48 object but when i debug images have only 23 objects.

Why aren't all my images loading?


Sounds like a problem with nil-termination. If one of your image objects (the 24th, probably) is coming back nil because of a typo in the name or a corrupt/non-existent image file, it will act like the final "nil" that terminates the list and your array will ignore everything after that. It's a common pitfall with arrayWithObjects: and dictionaryWithObjectsAndKeys:


You really shouldn't be loading that many images into memory on the iPhone OS, when you do that you have to load the whole RGB representation of the image, which isn't really something you want to be doing considering the resource constraints on the device.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜