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