I am developing an iPad
application. For some reasons, I need to show a two tableviews
in the same view controller. I have created a UIView
in a xib
and connected a outlet
to that view controller
. I need to show that view in those two tableviews as a tableHeaderView
. When I try to assign that view to both header views
, it is showing only in the second tableview
.I hope there is a single instance for that view. So it is showing on only in the view, which I assigned last. How could I overcome this?? Any help would be appreciated.
Here it is my code.
[energyTableView setTableHeaderView:tableHeader];
[maintenanceTableView setTableHeaderView:tableHeader];
@CodeBySteveZ
As he said, I created an xib and tried. And still I can't get the solution. Am I doing anything wrong??here it is how I tried.
NSArray *topLevelObjects = [[NSBundle mainBundle]loadNibNamed:@"tableHeaderCell" owner:nil options:nil];
[energyTableView setTableHeaderView:[topLevelObjects objectAtIndex:0]];
[maintenanceTableView setTableHeaderView:[topLevelObjects objectAtIndex:0]];
I think this is also a same thing as I did before.
@R.A I know its tedious to go programmatically but u can try this
Similarly add to other tableview a den release it.
Hope it helps.
You'll have to create another instance of the tableHeader. A UIView can only live in one visual sub-tree at a time. Using IB you could copy the element and create 2 instances of it. Or if you create a separate xib with that just element you could load that particular xib twice via code, once for each table header.
one view can not appear in two places.... said simplified one view == one superview