1
votes

I have a view controller that gets presented modally and changes some data that effects the data in a uitableview in the modal's parent view controller (a table view).

I call the tableview's reloadData method when the parent view reappears. I have confirmed that this code gets hit with a break point. My trouble is, reloadData isn't working. Here's the kicker - if I don't use reuseIdentifiers in the - (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath method, the data reloads correctly. It looks like the reuseIdentifier is to blame.

I really want to continue to use the reuseIdentifier for my cells - how do I make this work?

2

2 Answers

1
votes

Got it figured, and you're right, it's not the reuseIdentifer.

I was nesting the content assignment right below the cell allocation like so:

// Dequeue or create a cell of the appropriate type.
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

    cell.accessoryType = [targetRow.children count] ? UITableViewCellAccessoryDisclosureIndicator : UITableViewCellAccessoryNone;

// Configure the cell.
cell.textLabel.text = [NSString stringWithFormat: targetRow.title];
}

Since the dequeued cell was found, the content wouldn't get updated.

I changed it to this and all works great now...

// Dequeue or create a cell of the appropriate type.
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

}

cell.accessoryType = [targetRow.children count] ? UITableViewCellAccessoryDisclosureIndicator : UITableViewCellAccessoryNone;

// Configure the cell.
cell.textLabel.text = [NSString stringWithFormat: targetRow.title];
0
votes

The problem is unlikely to do with the reuse identifier. Please post your code for your tableView:cellForRowAtIndexPath: method.