Table view not reloading - cellForRowAtIndexPath not being called
My application is based on the SQLiteBooks tutorial from Apple. Instead of MasterViewController, I'm using CustomerViewController, i.e. books are now customers. All customer operations work as expected.
But I've added a new level below the customer level: projects. I've modified the customer view so that it now displays a blue accessorydetaildisclosure button. Clicking this button shows the customer details. And I've added the delegate method willSelectRowAtIndexPath. What this does is to first call a method on the appdelegate (getProjectsForCustomer) that queries the database for the selected customer's projects. Next, a ProjectViewController instance is created and then this is pushed onto the navigation controller.
The first time this is done, everything happens as expected:
the viewDidLoad method is first called, which just creates an add button on the nav bar.
Then the viewWillAppear method is called, which first gets the projects from the app delegate, and then calls reloadData on the tableview.
Then the cellForRowAtIndexPath is called repeatedly.
All as expected.
However; when I navigate back to the customer view, and then open another customer, only viewWillAppear is called on the project view (of course, the willSelectRowAtIndexPath is called on the customer view). The cellForRowAtIndexPath is not called, the result being that the same projects are being listed again, instead of the view redrawing itself based on the updated projects list.
Help is greatly appreciated!
// Marius
My application is based on the SQLiteBooks tutorial from Apple. Instead of MasterViewController, I'm using CustomerViewController, i.e. books are now customers. All customer operations work as expected.
But I've added a new level below the customer level: projects. I've modified the customer view so that it now displays a blue accessorydetaildisclosure button. Clicking this button shows the customer details. And I've added the delegate method willSelectRowAtIndexPath. What this does is to first call a method on the appdelegate (getProjectsForCustomer) that queries the database for the selected customer's projects. Next, a ProjectViewController instance is created and then this is pushed onto the navigation controller.
The first time this is done, everything happens as expected:
the viewDidLoad method is first called, which just creates an add button on the nav bar.
Then the viewWillAppear method is called, which first gets the projects from the app delegate, and then calls reloadData on the tableview.
Then the cellForRowAtIndexPath is called repeatedly.
All as expected.
However; when I navigate back to the customer view, and then open another customer, only viewWillAppear is called on the project view (of course, the willSelectRowAtIndexPath is called on the customer view). The cellForRowAtIndexPath is not called, the result being that the same projects are being listed again, instead of the view redrawing itself based on the updated projects list.
Help is greatly appreciated!
// Marius