Good morning all.
I'm having a small crisis with table views in a 3.1 app. I have a table view with some complex tableViewCells being loaded from a nib, and they're not being reused. Feeling it might have something to do with loading them from a nib, I decided to try a simple test project to see if cells are being reused using nothing but the basic apple template code. I started with the Navigation Based Template and here's the code for cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell.
cell.textLabel.text = [NSString stringWithFormat:@"%d", indexPath.row];
return cell;
}
I have a breakpoint set at the following line, and it's getting called on every pass.
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]
Setting the reuseIdentifier in the constructor as such:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"] autorelease];
}
Yields the same result, no cell reuse.
Thanks in advance for any help you can offer!