-1
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]];

}

}
4

1 回答 1

0

试试这个..

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

首先设置图像然后设置动画首先设置动画然后设置图像

 this [_playerImageView setImage:_imageData[1]] //This will set image from the array objectAtIndex 1.
于 2013-09-20T13:37:13.723 回答