Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>That is because toy are adding the views to your cell over and over again.</p> <p>You should only add them when you create the cell and just set the labels when the cell is being reused.</p> <p>You could set tags for your label, so that you can set it texts afterwards. The code bellow does the trick</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { if(style == UITableViewCellStyleValue1) cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; else cell = [[[UITableViewCell alloc] initWithStyle:style reuseIdentifier:CellIdentifier] autorelease]; NSInteger totalAvailableSpace = IPHONE_DISPLAY_WIDTH - iconSize - accesorySize - 10; NSInteger lableHeight = [[cellDetails objectForKey:@"TableItemTextFontSize"] intValue] * 2 + 10; UILabel *textLabel = nil; textLabel.tag = 1; textLabel = [[[UILabel alloc] initWithFrame:CGRectMake(iconSize+12, self.tableCellHeight/2 - lableHeight/2, totalAvailableSpace * 0.8, lableHeight)] autorelease]; textLabel.numberOfLines = 2; textLabel.lineBreakMode = UILineBreakModeWordWrap; textLabel.textAlignment = UITextAlignmentLeft; textLabel.text = [cellDetails objectForKey:@"TableItemMainText"]; if ([textLableColor scanHexInt:&amp;hex]) { textLabel.textColor = UIColorFromRGB(hex); } textLabel.font = [UIFont fontWithName:[cellDetails objectForKey:@"TableItemTextFontName"] size:[[cellDetails objectForKey:@"TableItemTextFontSize"] intValue]]; [cell.contentView addSubview:textLabel]; textLabel.backgroundColor = [UIColor clearColor]; lableHeight = [[cellDetails objectForKey:@"TableItemDetailTextFontSize"] intValue] * 2 + 10; UILabel *detailTextLabel = nil; detailTextLabel.tag = 2; detailTextLabel = [[[UILabel alloc] initWithFrame:CGRectMake(iconSize+10+totalAvailableSpace * 0.8+5, self.tableCellHeight/2 - lableHeight/2, totalAvailableSpace * 0.2 - 10, lableHeight)] autorelease]; detailTextLabel.numberOfLines = 2; detailTextLabel.lineBreakMode = UILineBreakModeWordWrap; detailTextLabel.textAlignment = UITextAlignmentLeft; detailTextLabel.text = [cellDetails objectForKey:@"TableItemDetailText"]; if ([detailTextLableColor scanHexInt:&amp;hex]) { detailTextLabel.textColor = UIColorFromRGB(hex); } detailTextLabel.font = [UIFont fontWithName:[cellDetails objectForKey:@"TableItemDetailTextFontName"] size:[[cellDetails objectForKey:@"TableItemDetailTextFontSize"] intValue]]; [cell.contentView addSubview:detailTextLabel]; detailTextLabel.backgroundColor = [UIColor clearColor]; } else { UILabel *textLabel = (UILabel *)[cell viewWithTag:1]; textLabel.text = [cellDetails objectForKey:@"TableItemMainText"]; UILabel *detailTextLabel = (UILabel *)[cell viewWithTag:2]; detailTextLabel.text = [cellDetails objectForKey:@"TableItemDetailText"]; } return cell; } </code></pre>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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