Custom UITableViewCell with UIProgressView
I'm using ASIHTTPRequest
to download files. My custom UITableViewCell
has UIProgressView
, it has a property to UIPRogressView
called: downloadProgressView
.
When I push downloads more, than tableView
can show in visible area, UIProgressView
working strange. Values of UIProgressView
in cells are mixed when I begin to scroll.
I download files asynchronously.
Here is method for creating new download.
-(void) pushDownload:(NSString *) url :(NSString *) fileName
{
[downloads addObject:fileName];
[downloadsTableView reloadData];
NSURL *url = [NSURL URLWithString:url];
//This is my custom cell
DownloadCell *cell = (DownloadCell *)[downloadsTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:[downloads indexOfObject:fileName] inSection:0]];
[cell.deleteDownloadButton setImage:[UIImage imageNamed:@"stop.png"] forState:UIControlStateNormal];
__block ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:url];
[request setDownloadDestinationPath:@"somepath"];
[request setDownloadProgressDelegate:cell.dowloadProgressView];
cell.currentRequest = request;
[request setShowAccurateProgress:YES];
cell.status = Downloading;
[request startAsynchronous];
}
And here is code for creating new cell:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"myCell";
DownloadCell *cell = (DownloadCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell==nil) {
NSArray *nibs = [[NSBundle mainBundle] loadNibNamed:@"DownloadCell" owner:nil options:nil];
for (id nibObject in nibs) {
if ([nibObject isKindOfClass:[DownloadCell class]]) {
cell = nibObject;
}
}
[cell.deleteDownloadButton setImage:[UIImage imageNamed:@"symbol_stop.png"] forState:UIControlStateNormal];
}
cell.textLabel.text = [a开发者_运维技巧udioDownloads objectAtIndex:indexPath.row];
if (cell.status==Downloaded) {
cell.dowloadProgressView.progress==1.0;
}
return cell;
}
Why progress view values are mixing when I begin to scroll?. Even when download finished values are still mixing sometimes.
精彩评论