Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>That happens because you are doing it wrong. You don't even need to reload the table. Just scroll around and you will notice it.<br> You create new labels and buttons each time a cell is displayed. And those UI elements are of course never removed. </p> <p>Add the UI element when you create a new cell and give them a tag. If the cell was successful dequeued get the element by that tag and set its values.</p> <p>Like this:</p> <pre><code>if (cell == nil) { // if no cell could be dequeued create a new one cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease]; // add label to the new cell UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(34,9,140,20)]; label.tag = 250; // &lt;---- save tag [label setFont:[UIFont fontWithName:@"Georgia" size:14]]; [label setNumberOfLines:0]; label.textAlignment = UITextAlignmentLeft; label.textColor = [UIColor whiteColor]; label.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight; label.backgroundColor = [UIColor clearColor]; //[imgView addSubview:label]; // I ignore this because I don't want to write 200 lines of code here. This is just an example so please adopt the code yourself [cell.contentView addSubView:label]; [label release]; } // whatever happened you have a cell with all the labels added here UILabel *label = (UILabel *)[cell.contentView viewWithTag:250] // &lt;---- get label with tag label.text = [arr objectAtIndex:1]; </code></pre> <hr> <p>and you don't need <code>if([appDelegate.dataArray count]&gt;0)</code>. If all your other tableview datasource methods are correct <code>tableView:cellForRowAtIndexPath:</code> isn't called if your data source is empty.</p> <hr> <p>Edit: Just saw that one:</p> <blockquote> <p>and in my code i am not able to use the method reuseTableViewCellWithIdentifier: because i want each label and button tag should be same because i have to fetch them else where.</p> </blockquote> <p>Actually you can. Everybody can and should use <code>reuseTableViewCellWithIdentifier:</code>.<br> What are your exact problems with that?<br> If you need to get the indexPath (or in your case only the row) in the button action method use the code from my <a href="https://stackoverflow.com/a/3911001/457406">answer to another question</a></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. 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