我的表格单元格显示有线响应..我有一个coustom表格表格视图,每个单元格中都有一个按钮和进度条..当我点击按钮时,书籍会下载,然后会出现进度条直到这本书下载,但当我点击第二个单元格的按钮进度条出现在第二单元格和第四单元格....我非常困惑,请提前帮助谢谢
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"Categorycell";
Categorycell *cell = (Categorycell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"Categorycell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
[tableView setSeparatorColor:[UIColor clearColor]];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
cell.cell_btn.tag = indexPath.row*10+1;
[cell.cell_btn addTarget:self action:@selector(btnDown:) forControlEvents:UIControlEventTouchUpInside];
cell.cell_ReadBtn.tag =indexPath.row*10+1;
[cell.cell_ReadBtn addTarget:self action:@selector(btnRead:) forControlEvents:UIControlEventTouchUpInside];
cell.cell_Progress.tag= indexPath.row*10+1;
if(!bIspress)
{
cell.cell_Progress.hidden=YES;
}
NSString *comicbook_id = [arr_comic_id objectAtIndex:indexPath.row];
NSString *filePath = [NSString stringWithFormat:@"book_%@.pdf",comicbook_id];
NSLog(@"Book Name : %@",filePath);
if(![appDelegate check_Book_available:filePath])
{
NSLog(@"Book Name Not : %@",filePath);
cell.cell_ReadBtn.hidden=YES;
cell.cell_btn.hidden= NO;
}
else
{
cell.cell_btn.hidden=YES;
cell.cell_ReadBtn.hidden=NO;
}
cell.tag=indexPath.row*10+1;
return cell;
}
-(void)btnDown:(UIButton*)sender
{
NSLog(@"Called when press");
// sender.hidden = YES;
dlIndex = sender.tag/10;
bIspress=true;
NSLog(@"INDEX : %d : %d",dlIndex,[sender tag]);
// Categorycell *cell = (Categorycell *)[self.tbl_view dequeueReusableCellWithIdentifier:@"Categorycell"];
// cell.cell_Progress.hidden=NO;
// [cell.cell_Progress setProgress:0.];
NSString *str_id=[arr_comic_id objectAtIndex:dlIndex];
[[NSUserDefaults standardUserDefaults] setValue:str_id forKey:@"book_id"];
// dlIndex = [sender tag]/10;
dlCell = (Categorycell *)[[sender superview]superview];
NSLog(@"INDEX progress : %d : Cell Tag : %d",dlCell.cell_Progress.tag,dlCell.tag);
NSIndexPath *path = [tbl_view indexPathForCell:dlCell];
if(dlCell.cell_Progress.tag==dlCell.cell_btn.tag)
{
[self Apicall_background];
}
// cell_Progressview = (UIProgressView* )[dlCell.contentView viewWithTag:dlIndex*10+1];
// cell_Progressview.hidden = NO;
}
答案 0 :(得分:0)
试试这个
-(void)btnDown:(UIButton*)sender
{
//your code
if(dlCell.cell_Progress.tag==dlCell.cell_btn.tag)
{
[self Apicall_background];
CGPoint center = CGPointMake(CGRectGetMidX(dlCell.bounds),
CGRectGetMidY(dlCell.bounds));
dlCell.cell_Progress.center = center;
}
}
答案 1 :(得分:0)
解决方案不好但这可以解决您的问题。
Categorycell *cell = (Categorycell *)[tableView dequeueReusableCellWithIdentifier:nil];