iphone - moving a UIImageView
I'm having difficulty moving an image to another location after the first animation is finished.
the image animates at a point that I've specified, then stops (that works fine). I would then like to move the image to another location and repeat.
here's my code:
-(void) loadTap {
NSArray *imageArray  = [[NSArray alloc] initWithObjects:
                                                        [UIImage imageNamed:@"tap1.png"],
                                                        [UIImage imageNamed:@"tap2.png"],
                                                        [UIImage imageNamed:@"tap3.png"],
                                                        [UIImage imageN开发者_开发知识库amed:@"tap4.png"],                                                       
                                                nil];
    tapImage.animationImages = imageArray;
    tapImage.animationRepeatCount = 1;
    [imageArray release];
    tapImage.animationDuration = 1;
    tapImage.animationRepeatCount = 20;
    [tapImage startAnimating];
    tapImage.center = CGPointMake(156, 110);
}
thanks for any help.
In order to move an image, you should enclose the code to move in an animation block:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
tapImage.center = CGPointMake(156, 110);
[UIView commitAnimations];
You can also give a method to execute upon completion of the animation with UIView setAnimationDidStopSelector: method. 
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animateImages)];
tapImage.center = CGPointMake(156, 110);
[UIView commitAnimations];
//other stuff
-(void)animateImages{
     [tapImage startAnimating];
}
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论