【发布时间】:2013-03-23 00:46:43
【问题描述】:
我是 Xcode 的新手,我试图从数组中提取一堆图片并将它们放在屏幕上,但通过调试器我看到我的 for 循环没有运行。
for (int i = 0; i <[imagePaths count]; i++)
{
NSLog(@"I'm loading a card");
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 250, 350)];
NSString *imgFilepath = [[NSBundle mainBundle] pathForResource:[imagePaths objectAtIndex:i] ofType:@"jpg"];
UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgFilepath];
[imgView setImage:img];
[self.view addSubview:imgView];
}
有没有人看到我缺少什么来完成这项工作?
【问题讨论】:
-
是
imagePaths等于nil? -
图片肯定是 .jpg 而不是 .png/.jpeg 格式? IMO 也可能导致问题。
标签: iphone xcode arrays debugging