I’ve seen similar questions, but none with the same issue.
In a UIViewController I have two UITableViews tableView1 and tableView2 (which is within a UIScrollView). The datasource and delegate on both tables are set to the UIViewController, which implements UITableViewDelegate and UITableViewDatasource protocols. The UIViewController is itself within a UITabBarController as follows:
- UITabBarController
- UIViewController
- UITableView (tableView1)
- UIScrollView
- UITableView (tableView2)
- UIViewController
Within the tableView:cellForRowAtIndexPath: I check which table and populate accordingly:
if (tableView == _tableView1) {
//do stuff for tableView1
} else {
//do stuff for tableView2
}
When the UIViewController appears only tableView1 is populated with data. Tapping on another tab and then back again finally populates tableView2.
If tableView1’s delegate and datasource are set to nil, tableView2 never gets populated. It appears that tableView2 only gets populated once tableView1 has been populated.
Can anyone help with this?
Many thanks.
In my question I state the iVars were
_tableView1and_tableView2. These were actually_indexTableViewand_tableView. Changing_tableViewto_gridTableViewseems to have solved this issue.