Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The problem is that you're adding the Image and Label subviews every time the cell is being called. Instead, you only want to add those subviews when you're creating the cell. Every time the cell gets called you just want to set the values of subviews. You'll want something like this (done off memory):</p> <pre><code>Special *special = [speciales objectAtIndex:indexPath.row]; static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 5, 60, 60)]; [imageView setTag:100]; [cell addSubview:imageView]; UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(80, 5, 220, 16)]; name.font = [UIFont fontWithName:@"Heiti SC" size:16]; [nameLabel setTag:101]; [cell addSubview:nameLabel]; UILabel *descriptionLabel = [[UILabel alloc] initWithFrame:CGRectMake(80, 21, 220, 50)]; [descriptionLabel setTag:102]; descriptionLabel.font = [UIFont fontWithName:@"Heiti SC" size:12]; descriptionLabel.textColor = [UIColor darkGrayColor]; descriptionLabel.lineBreakMode = UILineBreakModeWordWrap; descriptionLabel.numberOfLines = 3; [cell addSubview:descriptionLabel]; } UIImageView *img = (UIImageView *)[cell viewWithTag:100]; img.image = special.specialIconImage; [self addShadowToImage:img]; UILabel *name = (UILabel *)[cell viewWithTag:101]; name.text = special.specialName; UILabel *description = (UILabel *)[cell viewWithTag:102]; description.text = special.specialDescription; return cell; </code></pre>
 

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