iphone imageview序列动画 [英] iphone imageview sequence animation

查看:35
本文介绍了iphone imageview序列动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,尝试将简单的png序列动画放到我的应用中.我在IB中安装了第一个框架,并连接了石墨化动画出口. 序列中有54种png,名称从"Comp 1_0000.png"到"Comp 1_00053.png"

Hey, trying to put a simple png sequence animation into my app. I have the first frame in place in IB, and the graphanimation outlet connected to it. There are 54 pngs in the sequence with names "Comp 1_0000.png" to "Comp 1_00053.png"

这是我的代码.

 -(void)viewDidLoad{
 for (int i=0; i<53; i++) {
         graphanimation.animationImages = [NSArray arrayWithObjects:
                           [UIImage imageNamed:@"Comp 1_000%d.png",i]];
    }
    graphanimation.animationDuration = 1.00;
 graphanimation.animationRepeatCount = 1;
 [graphanimation startAnimating];
 [self.view addSubview:graphanimation];
    [super viewDidLoad];    
} 

我认为我使用i整数引用图像文件名的方式出了一些问题.有人可以帮我解决这个问题吗? 谢谢!

I think something is wrong with the way I am referencing the image filenames with the i integer. Can someone help me sort this sucker out? Thanks!

推荐答案

您不能将变量参数列表和格式参数传递给[UIImage imageNamed:].

You can't pass a variable argument list and format arguments to [UIImage imageNamed:].

也许尝试这样的事情?

...
NSMutableArray *array = [NSMutableArray arrayWithCapacity:54];
for (int i = 0; i < 54; ++i) {
  NSString *name = [NSString stringWithFormat:@"Comp 1_000%d.png",i];
  UIImage *image = [UIImage imageNamed:name];
  [array addObject:image];
}
graphAnimation.animationImages = array;
...

这篇关于iphone imageview序列动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆