I have a UITableView with 3 custom UITableViewCells that I'm currently dequeuing like so:
if (indexPath.row == 0) {
static NSString *CellIdentifier = @"MyCell1";
MyCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[MyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
return cell;
}
if (indexPath.row == 1) {
static NSString *CellIdentifier = @"MyCell2";
MyCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[MyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
return cell;
}
if (indexPath.row == 2) {
static NSString *CellIdentifier = @"MyCell3";
MyCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[MyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
return cell;
}
I've tried to do this multiple ways, but the problem is even though I'm still dequeueing them all with different identifiers, when I scroll the tableView around, sometimes my first cell appears in the location of my third cell and viceversa. There seems to be some weird caching going on.
Does anyone know why? Thanks.