播放帧动画时出现问题,代码如下

时间:2013-09-20 13:32:58

标签: iphone ios animation

about two questions 
/*

1。这个[_playerImageView setImage:_imageData [1]]

 what can it do ? why ?

2。如何[_playerImageView startAnimating]和       [_playerImageView setImage:_imageData [1]]的序列        影响结果     * /

- (void)loadDataAndAnimation
    {
    _imageData =@[[UIImage imageNamed:@"a"],
                    [UIImage imageNamed:@"b"],
                    [UIImage imageNamed:@"c"]];

    [_playerImageView setAnimationImages:self.imageData];
    [_playerImageView setAnimationDuration:5.0];
    [_playerImageView startAnimating];

    }

- (void)viewDidLoad
{
[super viewDidLoad];
[self loadDataAndAnimation];
}

- (IBAction)playGame:(UIButton *)sender
{
NSLog(@"%d",sender.tag);
if ([_playerImageView isAnimating])
{
    NSLog(@"stop");
    [_playerImageView stopAnimating];
    [_playerImageView setImage:_imageData[sender.tag]];
}else
{
    NSLog(@"start");
    [_playerImageView startAnimating];
    //  something wrong ?
    [_playerImageView setImage:_imageData[1]];

}

}

1 个答案:

答案 0 :(得分:0)

试试这个..

 [_playerImageView setImage:_imageData[1]];  // Set the Image for PlayerImageView
 [_playerImageView startAnimating];          // It will start animating

首先设置Image&然后动画设置 First animate&然后设置图像

 this [_playerImageView setImage:_imageData[1]] //This will set image from the array objectAtIndex 1.