Note that there are some explanatory texts on larger screens.

plurals
  1. POShowing progress view in corresponding cell when click a download button in a tableview cell
    text
    copied!<p>I am new to iphone.I am struck in my project at some task (i.e),I have a table view with 66 rows.In that i am placed different book names for each cell and place a download button to each book.My requirement is when we click on download button it shows the progress view in that particular cell only but i am getting in that particular cell but when i am drag the tableview it will shows the progress views in some that cells also.It is because of dequeue reusability concept but i dont know how to avoid this problem.I want even after drag the tableview it shows the progress view on the cell which i am click the download button (cell)</p> <p>here is my code below..</p> <pre><code>- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 66; } - (UITableViewCell *)tableView:(UITableView *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UIButton *downloadButton = nil; CustomCell *cell = [_tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { //here custom cell is another class in that we have the title label declaration cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; downloadButton = [UIButton buttonWithType:UIButtonTypeCustom]; downloadButton.frame = CGRectMake(220,10,50,30); [downloadButton setImage:[UIImage imageNamed:@"download.png"] forState:UIControlStateNormal]; [downloadButton addTarget:self action:@selector(downloadButtonClicked:) forControlEvents:UIControlEventTouchUpInside]; downloadButton.backgroundColor = [UIColor clearColor]; downloadButton.userInteractionEnabled = YES; downloadButton.highlighted = YES; downloadButton.tag = indexPath.row; NSLog(@"tag is %d",indexPath.row); [cell.contentView addSubview:downloadButton]; } NSString *titleLabel = [[appDelegate getBookNames]objectAtIndex:indexPath.row]; cell.TitleLabel.text = titleLabel; return cell; } -(void)downloadButtonClicked:(id)sender{ int index = [sender tag]; NSLog(@"index of the cell is %d",index); UIButton *button = (UIButton*)sender; UITableViewCell *cell = (UITableViewCell *)[[button superview] superview]; UILabel *titleLabel = (UILabel *)[cell viewWithTag:100]; NSLog(@"label text =%@",titleLabel.text); selectedBookTitle = titleLabel.text; NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSMutableArray *allDownloadLinks; biblePlayerViewController = [[BiblePlayerViewController alloc]init]; allDownloadLinks = [biblePlayerViewController allDownloadLinks]; NSLog(@"all Download Links are %@",allDownloadLinks); biblePlayerViewController.indexOfSelectedBookTitle = [[appDelegate getBookNames]indexOfObject:selectedBookTitle]; Download* download = [Download downloadWithTitle:selectedBookTitle url:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.audiotreasure.com/%@.zip",[allDownloadLinks objectAtIndex:(biblePlayerViewController.indexOfSelectedBookTitle)]]]PathtoSave:documentsPath]; [[DownloadManager sharedDownloadManager] queueDownload: download]; UITableViewCell *tableViewCell = [tableView cellForRowAtIndexPath:indexPath]; progressView.frame = CGRectMake(10, 40, 300, 20); [tableViewCell.contentView addSubview:progressView]; } </code></pre> <p><a href="http://i.stack.imgur.com/f9Rdi.png" rel="nofollow">screen shot</a> of my project is [output of my above code which is in simulator]</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload