Ios 循环图像的动画不显示
我从网上下载了动画篝火。我的图像序列是“*.png”,无法正常工作。它一直循环到最后。它不显示图像。为什么我不能为这段代码设置动画?我做错了什么Ios 循环图像的动画不显示,ios,xcode,loops,for-loop,jquery-animate,Ios,Xcode,Loops,For Loop,Jquery Animate,我从网上下载了动画篝火。我的图像序列是“*.png”,无法正常工作。它一直循环到最后。它不显示图像。为什么我不能为这段代码设置动画?我做错了什么 UIImageView* campFireView = [[UIImageView alloc] initWithFrame:screenx.frame]; int j; int i; for (j = 1, i = 0; i < 28; i =1) {
UIImageView* campFireView = [[UIImageView alloc] initWithFrame:screenx.frame];
int j;
int i;
for (j = 1, i = 0; i < 28; i =1)
{
NSLog( @"%i.png", i);
campFireView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:[NSString stringWithFormat:@"%i.png",i]], nil];
}
// all frames will execute in 1.75 seconds
campFireView.animationDuration = .15;
// repeat the annimation forever
campFireView.animationRepeatCount = 1;
// start animatinganimationRepeatCount:1];
[campFireView startAnimating];
// add the animation view to the main window
[self.view addSubview:campFireView];
[campFireView release];
UIImageView*campFireView=[[UIImageView alloc]initWithFrame:screenx.frame];
int j;
int i;
对于(j=1,i=0;i<28;i=1)
{
NSLog(@“%i.png”,i);
campFireView.animationImages=[NSArray arrayWithObjects:
[UIImage ImageName:[NSString stringWithFormat:@“%i.png”,i]],nil];
}
//所有帧将在1.75秒内执行
campFireView.animationDuration=.15;
//永远重复这个纪念日
campFireView.animationRepeatCount=1;
//开始动画AnimationRepeatCount:1];
[campFireView startAnimating];
//将动画视图添加到主窗口
[self.view addSubview:campFireView];
[campFireView发布];
每次打电话时:
UIImageView* campFireView = [[UIImageView alloc] initWithFrame:screenx.frame];
int j;
int i;
for (j = 1, i = 0; i < 28; i =1)
{
NSLog( @"%i.png", i);
campFireView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:[NSString stringWithFormat:@"%i.png",i]], nil];
}
// all frames will execute in 1.75 seconds
campFireView.animationDuration = .15;
// repeat the annimation forever
campFireView.animationRepeatCount = 1;
// start animatinganimationRepeatCount:1];
[campFireView startAnimating];
// add the animation view to the main window
[self.view addSubview:campFireView];
[campFireView release];
campFireView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:[NSString stringWithFormat:@"%i.png",i]], nil];
您正在将animationImages
设置为一项数组。您可能想做的是:
UIImageView* campFireView = [[UIImageView alloc] initWithFrame:screenx.frame];
int j;
int i;
for (j = 1, i = 0; i < 28; i =1)
{
NSLog( @"%i.png", i);
campFireView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:[NSString stringWithFormat:@"%i.png",i]], nil];
}
// all frames will execute in 1.75 seconds
campFireView.animationDuration = .15;
// repeat the annimation forever
campFireView.animationRepeatCount = 1;
// start animatinganimationRepeatCount:1];
[campFireView startAnimating];
// add the animation view to the main window
[self.view addSubview:campFireView];
[campFireView release];
NSMutableArray *animationImages = [NSMutableArray array];
for (i = 0; i < 28; i++)
{
[animationImages addObject:[UIImage imageNamed:[NSString stringWithFormat:@"%i.png",i]]];
}
campfireView.animationImages = animationImages;
NSMutableArray*animationImages=[NSMutableArray];
对于(i=0;i<28;i++)
{
[animationImages添加对象:[UIImage ImageName:[NSString stringWithFormat:@“%i.png”,i]];
}
campfireView.animationImages=animationImages;
另外-我不知道你的
for
循环发生了什么,但我修复了它。当你循环时,然后每次为animationImages提供一个图像
UIImageView* campFireView = [[UIImageView alloc] initWithFrame:screenx.frame];
int j;
int i;
for (j = 1, i = 0; i < 28; i =1)
{
NSLog( @"%i.png", i);
campFireView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:[NSString stringWithFormat:@"%i.png",i]], nil];
}
// all frames will execute in 1.75 seconds
campFireView.animationDuration = .15;
// repeat the annimation forever
campFireView.animationRepeatCount = 1;
// start animatinganimationRepeatCount:1];
[campFireView startAnimating];
// add the animation view to the main window
[self.view addSubview:campFireView];
[campFireView release];
NSMutableArray *arrImgs = [NSMutableArray array];
for (i = 0; i < 28; i++)
{
[arrImgs addObject:[UIImage imageNamed:[NSString stringWithFormat:@"%i.png",i]]];
}
campfireView.animationImages = [NSArray arrayWithArray:arrImgs];
NSMutableArray*arrImgs=[NSMutableArray];
对于(i=0;i<28;i++)
{
[arrImgs addObject:[UIImage ImageName:[NSString stringWithFormat:@“%i.png”,i]];
}
campfireView.animationImages=[NSArray arrayWithArray:arrImgs];
[animationImages添加对象:[UIImage ImageName:[NSString stringWithFormat:@“%i.png”,i]];代码在XCODE 4上显示为SIGABRT。5@user1692698嗯,你的for
循环被破坏得很厉害,所以无论如何只执行了一次,所以更正了我的答案。imageNamed
是否为i
的某个值返回一个nil图像?@user1692698是否解决了这个问题?为什么不使用%d.png
格式化程序而不是%i.png
?在for
循环的标题中,变量i
和j
的奇怪组合是什么?