开发者

iphone imageview sequence animation

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"

Here's my code.

 -(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]开发者_JS百科;
    [super viewDidLoad];    
} 

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!


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

Try something like this perhaps?

...
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;
...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜