Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableView as a tableHeaderView for another UITableView
    primarykey
    data
    text
    <p>I get stuck on the following: I want to use a single cell of a UITableView as a header view for another UITableView. The second table view is in turn an object that has been inherited from a different UITableView class, since it shares it's functionality completely. The only difference in fact is that the second UITableView has a header view (which should be the single celled UITableView). </p> <p>The interface for the UITableView with the header looks like:</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import "ScheduleDetailsController.h" @interface TodayDetailsViewController : ScheduleDetailsController &lt;UITableViewDelegate, UITableViewDataSource&gt; { UITableView *headerView; } @property (nonatomic, retain) UITableView *headerView; @end </code></pre> <p>And the implementation like:</p> <pre><code>#import "TodayDetailsViewController.h" @implementation TodayDetailsViewController @synthesize headerView; - (void)loadView { [super loadView]; self.headerView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)]; self.headerView.backgroundColor = [UIColor clearColor]; self.headerView.opaque = NO; self.headerView.delegate = self; self.headerView.dataSource = self; // This is a UITableView defined as a property in the parent class self.scheduleDetailsTable.tableHeaderView = self.headerView; } ... #pragma mark - #pragma mark Table View Data Source Methods - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { if (tableView == self.scheduleDetailsTable.tableHeaderView) return 1; else return [self.scheduleDetailsTable numberOfSections]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (tableView == self.scheduleDetailsTable.tableHeaderView) return 1; else return [self.scheduleDetailsTable numberOfRowsInSection:section]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (tableView == self.scheduleDetailsTable.tableHeaderView) { ... return cell; } else return [self.scheduleDetailsTable cellForRowAtIndexPath:indexPath]; } @end </code></pre> <p>I get no errors when I compile and run this, but then I also don't see anything, i.e. the view stays empty. I have also tried it with replacing the header view by a UIView and then everything works like expected (i.e. the table view in the parent class is implemented correctly). I'm probably just missing something obvious, but I just can't figure it out at the moment. If someone could spot the error or could give some advice I would be very thankful.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload