Question

I have a problemetic UITableViewController fails to redraw an updated cell after a child view is removed.

Here's what's happening. After changing data in a child view, the parent view controller reloads the source data array and runs [tableView reloadData] via a PostNotification. After this triggers, I use popViewControllerAnimated to return to the parent UITableViewController (this pops the child view off the stack, and reveals the controller one level up).

However, my updated data does not appear in the parent view controller! According to the debugger, the cell's label has been updated, but the visible label does not change. However, if I scroll-flick the table, momentarily moving the updated cell out of view, when it reappears the label is updated!

I also try calling [tableView reloadData] via viewWillAppear but the issue still persists.

Here is some additional info that may be helpful. I have a 3 views structured like this:

1/  SettingsViewController : UITableViewController
2/  -- UserView : UITableViewController
3/  ---- UserDetailsView : UIViewController <UIActionSheetDelegate>

I am calling UserDetailsView from inside UserView as follows:

 UserDetailsView *userDetailsView = [[UserDetailsView alloc] init];
 [self.navigationController pushViewController:userDetailsView animated:YES];

If I return to the top-most controller (SettingsViewController) and then load the problematic controller (UserView), everything is drawn correctly. It is only when returning from a child view that this issue occurs.

Thank you in advance for your suggestions.

Was it helpful?

Solution

Finally worked this one out after about an hour of paired coding.

After a while We noticed that tableView was always null whenever we sent the reloadData message. As you may know in Objective C, null objects accept any message without complaint.

It turns out that "someone" (ahem, sorry it was me) had defined this line in the header file.

 UITableView *tableView;

Now you smart cookies out there will know that because we extend UITaleViewController, we do not need to make a pointer to tableView ourselves. In effect I had replaced the inherited tableView member with a null object.

Mystery solved. Hopefully this helps someone else out there too! :D

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top