I want this label to be removed once the animation is done. And I'd like to not see it again while animating in the following code inside my touchesEnded function. I don't see a way to check if lbl.isAnimating already to ignore it in the for loop ( without creating my own list of UILabels ), but I would have thought my completion code here would work. But after the animation is over I still fall into the if point is inside block if I click 开发者_开发知识库on the invisible label.
for( lbl in mLabelOutletCollection ) {
if (CGRectContainsPoint([lbl frame], [touch locationInView:self.view]))
{
[UIView animateWithDuration:1.0 delay:0.0
options:(UIViewAnimationOptionAllowUserInteraction)
animations:^{
lbl.alpha = 0.0;
lbl.transform = CGAffineTransformMakeScale(1.5, 1.5);
}
completion:^(BOOL completed){
[lbl removeFromSuperview];
lbl.hidden=YES;
}
];
}
}
Override
- (void)finishAnimation:(NSString *)animationId finished:(BOOL)finished context:(void *)context {
And put the:
[lbl removeFromSuperview];
lbl.hidden=YES;
there. Also, not sure but I do not believe you need the second line lbl.hidden; since you are already removing it from the superview.
I solved this by adding a bool and doing this after the loop. Even though the lbl was removed, it still existed in the OutletCollection and remembered where it was. I had tried this before, but was doing it inside the loop which causes an exception.
if ( found ) [mLabelOutletCollection removeObject:lbl];
精彩评论