user639483
user639483

Reputation: 21

Two UITableViews in one UIViewController

I have a UIView. It contain two UIScrollView, and everyone UIScrollView contains one UITableView.

When I fill tables with data, the first table gets filled with data, but the second table remains empty.

What could be wrong?

After debugging I saw that

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

was called for first table only. but

(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

was called for every table!!! --> also no problems with delegate or datasource...

Please Help.

I am using the logic :

if(tableView == self.tableU1){
  ... 
  } 
else{
...
}

for differentiate the tables.

Upvotes: 2

Views: 5277

Answers (3)

GendoIkari
GendoIkari

Reputation: 11914

Other answers have hinted at this, but note that cellForRowAtIndexPath: is a datasource method, while viewForHeaderInSection: is a delegate method. It seems almost definite that you've hooked up your delegate to both, both only your datasource to one.

Upvotes: 0

Yanny
Yanny

Reputation: 500

Be sure you are setting delegate for both tables. And it must be your controller. If you are using Interface builder try to set delegate manualy:

tableView.delegate = self;

Upvotes: 0

occulus
occulus

Reputation: 17014

This question may be relevant:

iPad - More than one UITableView in the same screen

You're absolutely sure you've hooked up both the delegate and the data source for both tables, right? Double check!

Upvotes: 2

Related Questions