0

I am new to ios how to update a progress bar in uitableview. generally I have a button, when I click a button in a particular cell I need to show progress bar in that cell only please help me and thanks in advance

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

    NSLog(@"Index : %d",indexPath.row);
    NSString *str_filepath=[thumbnails objectAtIndex:indexPath.row];
   cell.cell_img.image=[[UIImage alloc]initWithContentsOfFile:str_filepath];

    cell.title.text=[arr_book objectAtIndex:indexPath.row];
    cell.sub_title.text=[arr_gen objectAtIndex:indexPath.row];
    NSString *str_rating=[arr_rating objectAtIndex:indexPath.row];
    int val_rating=[str_rating integerValue];

   // cell.cell_btn.hidden=YES;

    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;
}
Baby Groot
  • 4,637
  • 39
  • 52
  • 71
rakesh
  • 73
  • 3
  • 12
  • explain what you want to achieve i mean how the progress happen on cell click – Retro Nov 21 '13 at 13:49
  • i just need to show when i click the button in tablecell. i need to show progreess bar of those cell.i mean actually i hide progress bar after clicking button i need to show progressbar that's it please help me – rakesh Nov 21 '13 at 14:14
  • so u mean you are able to hide it but not able to show, add some screenshots – Retro Nov 22 '13 at 05:29
  • actually i have a button and progress bar in coustom table cell when i add coustom table cell in table view , should visible only button from coustom table cell in table view after clicking the button it should hide the button and display progress bar...thanks for ur reply – rakesh Nov 22 '13 at 07:14

1 Answers1

1
-(void) btnDown:(id)sender {
   UIButton* cellButton = (UIButton*)sender;
   NSIndexPath* selectedIndexPath = [NSIndexPath indexPathForRow:cellButton.tag inSection:0];
   UITableViewCell* cell = [self.tableView cellForRowAtIndexPath:selectedIndexPath];

   for (id subView in cell.containView) {
      if([subView isKindOfClass:[UIProgressView class]) {
        UIProgressView * cellProgressView = (UIProgressView*)subView;
        cellProgressView.frame = CGRectMake(10,10, 50,50); setYourFrame;
        [cellProgressView setHidden:NO];
      }
   }
}

I hope this view do

Retro
  • 3,985
  • 2
  • 17
  • 41