UITableViewCell重新加载时无法按下UIButton

时间:2012-04-17 10:56:52

标签: uitableview uiprogressview

我有一个tableview,其中包含下载和下载对象,其中下载单元格是自定义的,带有2个标签,1个UIProgressView和1个UIButton。

我的NSURLConnection委托将在下载对象时不断更新进度。然而,在重新装载电池的过程中,电池中的UIButton非常难以按下,我必须非常快地按下电池,这样它才会对我产生反应。我发现的问题是委托太频繁地刷新单元格(大约0.002秒),所以我在每次刷新之后将频率设置为0.1秒,但是UIButton仍然很难被按下,我无法设置间隔太长,因为这会使UIProgressview的更新不连续。

这是代表的代码:

- (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]; 
    }
  }

downloadsController.progress0是tableview的dataSource,用于更新进度视图。

如果我删除最后一行代码

[downloadsController.downloadsTableview reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexP] withRowAnimation:UITableViewRowAnimationNone];

然后可以正常按下UIButton。

知道如何解决问题?非常感谢你的帮助。

0 个答案:

没有答案
相关问题