I have a tableview which contains the downloaded and downloading objects, where the downloading cell is custom with 2 labels, 1 UIProgressView and 1 UIButton.
My NSURLConnection delegate will keep updating the progress when object is downloading. However, during the reloading of the cell, the UIButton in the cell is very hard to be pressed, that I have to keep press it very fast so that it would get response to me. The problem I find out is that the delegate refresh the cell too frequently (around 0.002 seconds), so I set the frequency to 0.1 second for each refreshing after that, but the UIButton is still very hard to be pressed, I can't set the interval too long because that would make the updating of the UIProgressview not continuous.
Here is my code for the delegate:
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
if(startTime == nil) startTime = [NSDate date];
NSDate *currentTime = [NSDate date];
NSTimeInterval timeInterval = [currentTime timeIntervalSinceDate:startTime];
bytesReceived = [receivedData length];
if (timeInterval >=0.1) {
startTime = currentTime;
double percent = bytesReceived/expectedBytes;
WVSecondViewController *downloadsController = [[WVSecondViewController alloc] initWithNibName:nil bundle:nil];
int index = [downloadsController.name0 indexOfObject:resourceName];
[downloadsController.progress0 replaceObjectAtIndex:index withObject:[NSNumber numberWithFloat:percent]];
NSIndexPath *indexP = [NSIndexPath indexPathForRow:index inSection:0];
[downloadsController.downloadsTableview reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexP] withRowAnimation:UITableViewRowAnimationNone];
}
}
the downloadsController.progress0 is the dataSource of the tableview which used to update progress view.
if I remove the last line of code
[downloadsController.downloadsTableview reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexP] withRowAnimation:UITableViewRowAnimationNone];
then the UIButton can be pressed normally.
Any idea how can I solve the problem? Many thanks for every help.