Permalink
Browse files

Merge pull request #20 from miketsprague/master

Fixed a bug that cancelled the animation timer and made the pie chart disappear whenever the user clicks on the animating chart.
  • Loading branch information...
2 parents 04a1285 + 91a50a5 commit bb45cb234d476aa63ec0b5a7933d520cbc3f0b79 @xyfeng committed Mar 8, 2013
Showing with 5 additions and 1 deletion.
  1. +5 −1 XYPieChart/XYPieChart.m
View
@@ -459,7 +459,11 @@ - (void)animationDidStart:(CAAnimation *)anim
{
if (_animationTimer == nil) {
static float timeInterval = 1.0/60.0;
- _animationTimer= [NSTimer scheduledTimerWithTimeInterval:timeInterval target:self selector:@selector(updateTimerFired:) userInfo:nil repeats:YES];
+ // Run the animation timer on the main thread.
+ // We want to allow the user to interact with the UI while this timer is running.
+ // If we run it on this thread, the timer will be halted while the user is touching the screen (that's why the chart was disappearing in our collection view).
+ _animationTimer= [NSTimer timerWithTimeInterval:timeInterval target:self selector:@selector(updateTimerFired:) userInfo:nil repeats:YES];
+ [[NSRunLoop mainRunLoop] addTimer:_animationTimer forMode:NSRunLoopCommonModes];
}
[_animations addObject:anim];

0 comments on commit bb45cb2

Please sign in to comment.