aaronium112
aaronium112

Reputation: 3088

How to get reloadData to work on UITableView

I have a UITableView that loads from a NIB file. The controller for the screen is a subclass of UIViewController that conforms to the UITableView delegate protocols. This is the 2nd screen in a stack of views managed by a UINavigationController.

In my viewWillAppear for the offending view I run two NSFetchRequests and update 2 of the 3 sections in my table with results from those NSFetchRequests. At the bottom of viewWillAppear I call

[self.myTable reloadData];

myTable is an IBOutlet to the UITableView for the screen.

For whatever reason the table doesn't reload the data and none of the delegate methods for the table get called when I come back up to it from views deeper in the Navigation Controller hierarchy.

How do I get the table to reload?

Thanks.

Upvotes: 4

Views: 11799

Answers (2)

W Dyson
W Dyson

Reputation: 4634

Have you also linked the UITableView to data source and delegate outlets in the nib file? You have to link these two in addition to the IBOutlet.

Upvotes: 1

WrightsCS
WrightsCS

Reputation: 50707

Instead of self.tableView, use:

[myTable reloadData];

So if you defined your IBOulet as myTable, then you need to use that name instead.

self.myTable would work if you initialized myTable like in your header:

self.myTable = [[UITableView alloc] initWithFrame:CGRectZero];

Upvotes: 6

Related Questions