我iphone的初學者,我在陣列中的所有圖像,但如何顯示一個接一個,當我在一個循環中執行陣列..如何在陣列中一個一個地顯示圖像?
NSArray *images = [[NSArray arrayWithObjects:
[UIImage imageNamed:@"1.png"],
[UIImage imageNamed:@"2.png"],
[UIImage imageNamed:@"3.png"],
[UIImage imageNamed:@"4.png"],
nil] retain];
int i=0;
int width = 0;
int height = 0;
for (NSString *imageName in images)
{
//NSTimer *timer=[[NSTimer alloc]init];
UIImage *image = [images objectAtIndex:i];
//UIImage *image = [UIImage imageNamed:imageName];
animalphoto = [[UIImageView alloc] initWithImage:image];
animalphoto.contentMode = UIViewContentModeScaleAspectFit;
animalphoto.clipsToBounds = YES;
animalphoto.animationDuration=5.0;
animalphoto.animationRepeatCount=0;
animalphoto.frame = CGRectMake(animalphoto.frame.size.width * i++, 0, animalphoto.frame.size.width, animalphoto.frame.size.height);
width = animalphoto.frame.size.width;
height = animalphoto.frame.size.height;
NSLog(@"print:%@",image);
[animalphoto release];
}
}
給出任何建議和示例代碼,這是適用於我們的代碼..
使用此方法: 'imgView.animationImages = images;' – Dhruv 2012-07-05 11:13:49