dequeueReusableCellWithIdentifier messing up custom cells solution
This problem actually took me quite a while to fix. It is basiclally this. When you have a longer UITableView with custom cells and you scroll, the cell elements get randomly duplicated. It is because the cells have all the same identifier and dequeueReusableCellWithIdentifier was using them in wrong places. In the end I found several solutions but the best one is to actually set a unique identifier for each cell.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *CellIdentifier = [NSString stringWithFormat:@"Cell %d, %d", indexPath.row, indexPath.section]; //this is where each cell gets uniquie identifier which prevents any problems UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } // setup your custom cell... return cell; }