how UITableView and UILabel repeating
This has just completely stomped me.
I have a custom UIView and UILable that I have added to my UITableView in cell.contentView as a subview. I have an array called arryData with about 100 strings as data in it that I want to show in my table. The problem is that when table is created I see the first 0-4 rows from my arryData with values and if I keep scrolling down the table, all I see are the first 5 strings repeating over and over. What am I doing wrong? here is my code.
This is what my output looks like when I scroll down the table and all I keep seeing is text in my labelValue1 from indexPath.row 0 – 4 repeat over and over
Change the way you are setting tag in this case,
and read it as,
Since you are dequeuing the cells, it will try to reuse the cell and label is added to that when you are allocating memory for the cell. When the else part is executed, you need to access the same label which was already added as