Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I just'd been through a similar problem actually when you set the frame of the imageView on line </p> <pre><code> [imageView setCenter:CGPointMake(240, 160)]; </code></pre> <p>the imageView gets settled at that point in the memory, It's just that due to being in animation block it's showing you the transition that imageView is being moved towards the destination but in actual the view's coordinates are assigned with the destination location, you can confirm it by logging coordinates right after the line of code. If you really need to do this the similar way, you can use the timer instead of the animation block and animate yourself. But I circumvent this problem by using the animationDelegate. Just set animation delegate to self and define animationDidStopSelector and you're up. You're animationDidstopSelector will get fired when the animation's ended and hence the object reached it's final destination or you can say there's a collision (on UI). Hope that helps<br> Here's a code sample: </p> <pre><code>- (void)createNewImageView { // Get the view's frame to make it easier later on UIImage *image = [UIImage imageNamed:@"abouffer_03.png"]; UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; // Add it at a random point [imageView setCenter:[self randomPointSquare]]; [[self view] addSubview:imageView]; // Animate it into place [UIView beginAnimations:nil context:nil]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(animationDidStop:)]; [UIView setAnimationDuration:8.0f]; [imageView setCenter:CGPointMake(240, 160)]; [UIView commitAnimations]; [imageView release]; } </code></pre> <p>your animationDidStopSelector will be just like: </p> <pre><code>-(void)animationDidStop:(id)sender { //This is almost similar to collision detection, you can do something here } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload