Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Attempting to trigger a method at the end of your animation with a timer is ill-advised. Instead, you should be using the <code>setAnimationDidStopSelector:</code> class method within your animation block. On top of that, because of the way you are using num to handle removing objects from the array, you are guaranteed to exceed the bounds of the array at some point during one of the invocations of animationEnded. It would be better to reference the object itself, rather than its position in the array. This is what the context parameter in the <code>beginAnimations:context:</code> method is for:</p> <pre><code>- (void)moveObjs { for (int i = 0; i &lt; [particlesArray count]; i++) {         animID = @"MoveId";         UIImageView *imgV = [particlesArray objectAtIndex:i];         [UIView beginAnimations:nil context:imgV];         [UIView setAnimationDuration:0.3]; [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];         CGPoint randPoint = CGPointMake(arc4random()%kMaxRandX, arc4random()%kMaxRandY);         imgV.center = CGPointMake(randPoint.x, randPoint.y);         [UIView commitAnimations];     } } - (void)animationDidStop:(NSString *)animID finished:(NSNumber *)finished context:(void *)context {   UIImageView *iv = (UIImageView *)context;     if ([animID isEqualToString:@"MoveId"]) {         [UIView beginAnimations:nil context:NULL];         [UIView setAnimationDuration:0.1];         iv.alpha = 0.0f;         [UIView commitAnimations]; [particlesArray removeObject:iv];     } else {         [iv removeFromSuperview];     } } </code></pre> <p>NOTE: If you are not supporting versions prior to iOS 4, then you should switch to using the new Blocks based methods, such as <code>animateWithDuration:animations:completion:</code>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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