How to get reloadData to work with UITableView

I have a UITableView that is loading from a NIB file. The screen controller is a subclass of UIViewController that conforms to the UITableView delegate protocols. This is the second screen in the view stack, managed by the UINavigationController.

In my WillAppear view for the breaking view, I run two NSFetchRequests and update 2 of 3 sections in my table with the results of these NSFetchRequests. At the bottom of viewWillAppear, I call

[self.myTable reloadData]; 

myTable is an IBOutlet for a UITableView for the screen.

For some reason, the table does not reload the data, and none of the delegate methods for the table are called when I return to it from the views deeper in the hierarchy of the navigation controller.

How to get a table to reload?

Thanks.

+4
source share
2 answers

Instead of self.tableView use:

 [myTable reloadData]; 

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

self.myTable will work if you initialized myTable, as in your header:

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

Have you also linked the UITableView to the data source and delegated the outputs in the nib file? You must link the two in addition to IBOutlet.

+1
source

Source: https://habr.com/ru/post/1338923/


All Articles