Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy old value appeared in tableViewCell
    primarykey
    data
    text
    <p>I added a UILabel when TableViewCell making. Code like this:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { Special *special = [speciales objectAtIndex:indexPath.row]; ...... UILabel *description = [[UILabel alloc] initWithFrame:CGRectMake(80, 21, 220, 50)]; description.text = special.specialDescription; description.font = [UIFont fontWithName:@"Heiti SC" size:12]; description.textColor = [UIColor darkGrayColor]; description.lineBreakMode = UILineBreakModeWordWrap; description.numberOfLines = 3; [cell addSubview:description]; return cell; } </code></pre> <p>It works well, but when I scrolled it from the bottom to top, and when I selected a row, the old value appeared at the same time. Who can help me fix this?</p> <p>Thank you!</p> <p>update : All of my codes is this: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {</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 *img = [[UIImageView alloc] initWithFrame:CGRectMake(10, 5, 60, 60)]; img.image = special.specialIconImage; [self addShadowToImage:img]; [cell addSubview:img]; UILabel *name = [[UILabel alloc] initWithFrame:CGRectMake(80, 5, 220, 16)]; name.text = special.specialName; name.font = [UIFont fontWithName:@"Heiti SC" size:16]; [cell addSubview:name]; UILabel *description = [[UILabel alloc] initWithFrame:CGRectMake(80, 21, 220, 50)]; description.text = special.specialDescription; description.font = [UIFont fontWithName:@"Heiti SC" size:12]; description.textColor = [UIColor darkGrayColor]; description.lineBreakMode = UILineBreakModeWordWrap; description.numberOfLines = 3; [cell addSubview:description]; return cell; </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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