I have a
UITableViewController which in it's
tableView:didSelectRowAtIndexPath method, sets up a view controller, and calls
[self.navigationController pushViewController: viewController animated:YES].
When i select a row in the root controller, the second viewController loads but is empty - table view loads but has no data. Here,
tableView:numberOfRowsInSection is not called.
When i return to the top level, and then select the same row again, the view loads correctly - method called.
Why would the table view not call the delegate methods on the fist attempt, but call them on the second?
Am i missing something obvious?
Solved by using
initWithNibName instead of
initWithStyle - knew it would be something obvious.
When you say:
When i select a row in the root controller, the second viewController loads but is empty.
Do you mean that the view is present but contains no data or do you mean that the table disappears to be replaced by blank/empty view?
If it is the former, then you need to make sure that the second level view controller has proper access to the data before you push it on the stack so that it can populate its view.
If it is the latter, it sounds like your second level view controller is not properly initializing its view the first time it is called. If you use a nib, check in Interface Builder that the controller has an outlet pointing to the view. If you create the view programmatically, check that the view is being initialized properly before it is called to display.