我在这个问题上坚持了几个小时。我的表格视图中有 3 行。我还使用包含 1 个按钮和 1 个进度条的自定义单元格。问题是当我点击第一行或第二行的按钮时,进度条总是显示在第三行。我不知道为什么。但我想显示与我们单击的行相对应的进度条。
@interface ViewController_ ()
{
CustomViewCell *cell;
}
@end
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
cell = (CustomViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell==nil) {
NSArray *nib;
nib = [[NSBundle mainBundle] loadNibNamed:@"IssueViewCell" owner:self options:nil];
for (id oneObject in nib)
if ([oneObject isKindOfClass:[CustomViewCell class]])
cell = (CustomViewCell *)oneObject;
}
cell.progressBar.hidden = YES;
[cell.downloadButton setTitle:@"Download" forState:UIControlStateNormal];
[cell.downloadButton addTarget:self action:@selector(downloadButtonCliked:) forControlEvents:UIControlEventTouchUpInside];
}
-(void) downloadButtonCliked:(UIButton *)sender{
NSLog(@"Called when press");
cell.progressBar.hidden = NO;
}