continuous animation within UITableViewCell
I'm trying to add a continuous animation onto my UITableViewCell-Subclass. It's a rather easy one with an Image fading in and out (fading between 0.4 alpha and 1.0), what I've tried so far ist the following:
-(void)animateRecordingIndicator{
[UIView beginAnimations:@"RecordingIndicatorAnimation" context:nil];
[UIView setAnimationDuration:0.3];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationFinished)];
if (animatedImageView.alpha == 0.4)
animatedImageView.alpha = 1.0;
else
animatedImageView.alpha = 0.4;
[UIView commitAnimations];
}
the code within animationFinished is as follows:
-(void)animationFinished{
if (doShowAnimation) {
[self performSelectorOnMainThread:@selector(an开发者_StackOverflow中文版imateRecordingIndicator) withObject:nil waitUntilDone:YES];
}
}
what I expect should be clear by now, but what I get is simply a crash with Xcode loading Stackframes more or less eternally :)
According to the UIView class reference, you are now discouraged from using the commitAnimations method. Instead use the following:
animateWithDuration:delay:options:animations:completion:
I imagine the infinite recursion you are encountering is related to Apple's reasons for making that recommendation.
精彩评论