activity indicator only animates once
i have created a custom "load more" cell at the bottom of my table view. And am trying to animate a activity indicator while the table is being populated with 5 more rows. Because the data loads too quickly, i have put a 2 sec timer to delay the process and want to show the indicator animation.
I seem to be able to get the i开发者_C百科ndicator animated once then it wont animate any more, however the rest of the code still executes and works fine.
here is my code for when user selects the cell...
[moreCellIndicator startAnimating];
//setup activity indicator timer
NSTimer *activityTimer = [NSTimer scheduledTimerWithTimeInterval: 2.0
target: self
selector:@selector(loadMoreTimer:)
userInfo: nil repeats:NO];
here is the code that triggers after the timer...
- (void) loadMoreTimer:(NSTimer *)theTimer {
//stop animating activity indicator
[moreCellIndicator stopAnimating];
//refresh table
... data gets reloaded
}
for some reason the first time the code is run the indicator will animate, but any more presses and it wont animate.
any help would be appreciated.
chris
edit: moreCellIndicator is declared like so...
UIActivityIndicatorView *moreCellIndicator;
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *moreCellIndicator;
Try to release
the activity indicator after you stop it, and initialize it before you start it:
moreCellIndicator = [UIActivityIndicatorView alloc] init];
and instead of using NSTimer
use:
[self performSelector:@selector(loadMoreTimer:) withObject:self afterTimeDelay:2];
And change your method to (id):sender
- (void)loadMoreTimer:(id)sender
精彩评论