0
当我放入一个图像url阵列时,这会崩溃,我认为它是因为我创建了UIImageView,然后尝试用相同的名称再次尝试!Cocoa Touch:在for循环中添加图像
- (void)cycleImages:(NSArray *)images {
int fromLeft = 5;
for(int n = 0; n <= [images count]; n++){
UIImageView *myImageView = [[UIImageView alloc] initWithImage:[[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[images objectAtIndex:n]]]]];
myImageView.frame = CGRectMake(fromLeft, 5, 48, 48); // from left, from top, height, width
fromLeft = fromLeft + 53;
//add image view to view
[self.view addSubview:myImageView];
NSLog(@"%@", [images objectAtIndex:n]);
}
}
任何想法? 谢谢! Dex