# Changing location after CommitAnimations

I'm using the following code to move a UIImageView:

shootImg.image = [UIImage imageNamed:@"Projectile Left 1.png"];
[UIView beginAnimations:nil context:nil];
shootImg.center = CGPointMake(shootImg.center.x+1000, shootImg.center.y);
[UIView commitAnimations];


This works but what I want to do is after [UIView CommitAnimations]; I want to set the location of shootImg using CGPointMake. If I just put it after commitAnimations then the animation doesn't fully complete. Any suggestions? I'm not using any frameworks like cocos2d and if you need to see any more code just ask.

You could add inside the [UIView beginAnimations:nil context:nil]; and [UIView commitAnimations]; add the following line: [UIView setAnimationDelegate:self]; and create this methods on your class: setAnimationWillStartSelector: and setAnimationDidStopSelector:

so your code will be like this:

shootImg.image = [UIImage imageNamed:@"Projectile Left 1.png"];
[UIView beginAnimations:nil context:nil];
shootImg.center = CGPointMake(shootImg.center.x+1000, shootImg.center.y);
[UIView setAnimationDelegate:self];
[UIView commitAnimations];


and on your class this methods:

+ (void)setAnimationDidStopSelector:(SEL)selector
+ (void)setAnimationWillStartSelector:(SEL)selector


if you like to see more i recommend the documentation for UIView here