I have a custom cell for a UITableView. The custom cell has a UIProgressView. I would like to set the progress for each cell's progressView with animation at the same time for all cells. The animation should start at viewDidAppear.
Asked
Active
Viewed 401 times
1 Answers
0
You can use NSTimer to control the animation and create a global progressView to control the cells' progressView. So:
UIProgressView *progressGlobal;
- (void)viewDidAppear:(BOOL)animated
{
NSTimer *timer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(increaseProgress) userInfo:nil repeats:YES];
[timer fire];
}
- (void)increaseProgress
{
[progressGlobal setProgress:(progressGlobal.progress + 5) animated:YES];
[[self tableView] reloadData];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *voCell = [tableView dequeueReusableCellWithIdentifier:TABLE_VIEW_CELL_IDENTIFIER forIndexPath:indexPath];
UIProgressView *localProgress = (UIProgressView *)[voCell viewWithTag:25];
[localProgress setProgress:progressGlobal.progress animated:YES];
}

Henrique Barros
- 868
- 7
- 12