Flo*_*dev 3 cocoa-touch objective-c uiimage ios
我有一张带有5张照片的NSArray.我想在循环中一个接一个地显示它们.我的代码:
NSArray *tabImage = [[NSArray alloc] init];
tabImage = [[NSArray arrayWithObjects:
[UIImage imageNamed:@"picto_1.png"],
[UIImage imageNamed:@"picto_2.png"],
[UIImage imageNamed:@"picto_3.png"],
[UIImage imageNamed:@"picto_4.png"],
[UIImage imageNamed:@"picto_5.png"],
nil] retain];
int var = 0;
var = indexPath.row;
for (int var = 0; var < 20; var++) {
pictoImage.image = [tabImage objectAtIndex:(var % 5)];
}
Run Code Online (Sandbox Code Playgroud)
我一直都有同样的照片.
感谢帮助.
我猜pictoImage
是一个UIImageView
.在这种情况下,请查看类引用,特别是animationImages
属性.
pictoImage.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"picto_1.png"],
[UIImage imageNamed:@"picto_2.png"],
[UIImage imageNamed:@"picto_3.png"],
[UIImage imageNamed:@"picto_4.png"],
[UIImage imageNamed:@"picto_5.png"],
nil];
// How many seconds it should take to go through all images one time.
pictoImage.animationDuration = 5.0;
// How many times to repeat the animation (0 for indefinitely).
pictoImage.animationRepeatCount = 4;
[pictoImage startAnimating];
Run Code Online (Sandbox Code Playgroud)