Note that there are some explanatory texts on larger screens.

plurals
  1. POCan not show correct image when reload tableview in ios
    text
    copied!<p>I have a problem : I want to reload tableview but it only reload label, i can not reload image of button. This is my codes:</p> <pre><code> - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [_tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; UILabel *FileNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 100, 30)]; FileNameLabel.tag = 1000; FileNameLabel.backgroundColor = [UIColor clearColor]; FileNameLabel.font = [UIFont fontWithName:@"Helvetica" size:16]; FileNameLabel.font = [UIFont boldSystemFontOfSize:16]; FileNameLabel.textColor = [UIColor blackColor]; NSLog(@"AllItemsArrayarray: %@", AllItemsArray); // FileNameLabel.text =[temp objectAtIndex:indexPath.row]; [cell.contentView addSubview: FileNameLabel]; [FileNameLabel release]; UILabel *UploadTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 20, 150, 25)]; UploadTimeLabel.tag = 2000; UploadTimeLabel.backgroundColor = [UIColor clearColor]; UploadTimeLabel.font = [UIFont fontWithName:@"Helvetica" size:12]; UploadTimeLabel.textColor = [UIColor grayColor]; // UploadTimeLabel.text = [UploadTimeArray objectAtIndex:indexPath.row]; [cell.contentView addSubview: UploadTimeLabel]; [UploadTimeLabel release]; UILabel *pricelabel = [[UILabel alloc] initWithFrame:CGRectMake(80, 0, 80, 30)]; pricelabel.backgroundColor = [UIColor clearColor]; pricelabel.font = [UIFont fontWithName:@"Helvetica" size:16]; pricelabel.font = [UIFont boldSystemFontOfSize:16]; pricelabel.textColor = [UIColor darkGrayColor]; pricelabel.tag = 3000; //pricelabel.hidden = YES; pricelabel.textAlignment = NSTextAlignmentRight; [cell.contentView addSubview: pricelabel]; [pricelabel release]; market = [UIButton buttonWithType:UIButtonTypeCustom]; market.tag = 4000; // [market addTarget:self action:@selector(marketPressedAction:) forControlEvents:UIControlEventTouchDown]; // [market setTag:indexPath.row]; [market setFrame:CGRectMake(200, 6, 30, 30)]; [cell.contentView addSubview:market]; } marketButton = (UIButton*)[cell.contentView viewWithTag:4000]; if([sellingArray count]&gt;0) { NSLog(@"sellingArray %@",sellingArray); if([[sellingArray objectAtIndex:indexPath.row] isEqualToString:@"0"]) // nothing { [marketButton setSelected:NO]; [marketButton setImage:[UIImage imageNamed:@"Marketplace.png"] forState:UIControlStateNormal]; marketButton.enabled = YES; } else if([[sellingArray objectAtIndex:indexPath.row] isEqualToString:@"2"]) // marketplace { [marketButton setSelected:YES]; [marketButton setImage:[UIImage imageNamed:@"MarketplaceSelect.png"] forState:UIControlStateNormal]; marketButton.enabled = YES; // auctionButton.enabled = NO; } } [marketButton addTarget:self action:@selector(marketPressedAction:) forControlEvents:UIControlEventTouchDown]; [marketButton setTag:indexPath.row]; //} if( [temp count] &gt; 0) { UILabel *fileNameLbl = (UILabel*)[cell.contentView viewWithTag:1000]; fileNameLbl.text =[temp objectAtIndex:indexPath.row]; UILabel *uploadlbl = (UILabel*)[cell.contentView viewWithTag:2000]; uploadlbl.text =[UploadTimeAllArr objectAtIndex:indexPath.row]; } if([priceNewArray count]&gt; 0) { UILabel *pricelbl = (UILabel*)[cell.contentView viewWithTag:3000]; pricelbl.text =[NSString stringWithFormat:@"$%@",[priceNewArray objectAtIndex:indexPath.row]]; if ([sellingArray count]&gt;0) { if([[sellingArray objectAtIndex:indexPath.row] isEqualToString:@"2"]){ pricelbl.hidden = NO; } else if([[sellingArray objectAtIndex:indexPath.row] isEqualToString:@"0"]){ pricelbl.hidden = YES; } } } UIImage *image = [UIImage imageNamed:@"More.png"]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; CGRect frame = CGRectMake(0.0, 0.0, image.size.width, image.size.height); button.frame = frame; // match the button's size with the image size //[button setBackgroundImage:image forState:UIControlStateNormal]; [button setImage:image forState:UIControlStateNormal]; // set the button's target to this table view controller so we can interpret touch events and map that to a NSIndexSet [button addTarget:self action:@selector(checkButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside]; button.backgroundColor = [UIColor clearColor]; cell.accessoryView = button; _tableView.contentInset = UIEdgeInsetsMake(0, 0, 100, 0); return cell; } </code></pre> <p>I used above code, when call <code>[table reloaddata]</code> , all label reloaded except button (button market) not show correct image. I don't know why so. Can you give any suggestion? Thanks in advance</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