Reputation: 32247
I've noticed the cells are taken out of memory when scrolled out of view and then added back into memory when scrolled into view.
I get the performance reasons for this, but since my table only has a couple of cells out of view, is there a way to turn off this caching feature?
Upvotes: 0
Views: 843
Reputation: 10069
You could try using a different cell identifier for each index path.
That way, the UITableView
won't be able to find a cell to dequeue, and a new one will be provided.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString * CellIdentifier = [NSString stringWithFormat:@"%d - %d", indexPath.row, indexPath.section];
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
return cell;
}
You could also skip queuing/dequeing entirely, and retain a reference to them yourself, then just return them in the cellForRowAtIndexPath
:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
return [myCells objectAtIndex:indexPath.row];
}
Where myCells
is an array holding your UITableViewCell
s.
Upvotes: 1