Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you look at the code your putting in your only assigning the value to the UILabel the first time the cell is created, on any dequeue methods where cell != nil then you just change the font and color for the label already in the cell since your using StyleValue1</p> <pre><code>// add description UILabel *text = [[UILabel alloc] initWithFrame:CGRectMake(15,25, 260, 50)]; text.numberOfLines=3; text.text= [[data objectAtIndex:indexPath.row] desc]; text.backgroundColor=[UIColor clearColor]; text.textAlignment= UITextAlignmentRight; text.font = [UIFont fontWithName:@"Helvetica" size:13]; [cell addSubview:text]; </code></pre> <p>You do not need this if you just use the label that is associated already with the cell, otherwise if you do need this then you should give the label tag so that you can retrieve it again from the cell when you go to display.</p> <p>Also your adding the subview to the cell instead of the content view of the cell. </p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath </code></pre> <p>{ UILabel *text; NSString *identifier = [NSString stringWithFormat:@"cell%d", indexPath.row];</p> <pre><code>MyCell *cell = (MyCell*)[tableView dequeueReusableCellWithIdentifier:identifier]; if (cell == nil) { cell = [[MyCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier]; // add description text = [[UILabel alloc] initWithFrame:CGRectMake(15,25, 260, 50)]; text.numberOfLines=3; text.backgroundColor=[UIColor clearColor]; text.tag = 1000; text.textAlignment= UITextAlignmentRight; text.font = [UIFont fontWithName:@"Helvetica" size:13]; [cell addSubview:text]; } else { text = (UILabel*)[cell viewForTag:1000]; } // Here you update the value of text text.text= [[data objectAtIndex:indexPath.row] desc]; //use your cell here cell.textLabel.textAlignment=UITextAlignmentRight; cell.textLabel.numberOfLines =3; // cell font cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:13.0]; cell.textLabel.textColor=[UIColor blackColor]; return cell; } </code></pre>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. 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