I made a UITableView
and set the "delegate" and "datasource" and every time I call reloadData
, it goes into the method:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [self.headersList count];
}
And the method:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
SectionInfo *headerInfo = (self.headerInfoArray)[section];
NSInteger numOfObjectsInSection = [[headerInfo.list objectsInList] count];
return headerInfo.open ? numOfObjectsInSection : 0;
}
And then stops! it doesn't go into the ViewForHeaderInSection:
method. I have also implemented the method:
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return SECTION_HEADER_HEIGHT;
}
The viewForHeaderInSection
method:
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UISectionHeaderView *sectionHeaderView = [[UISectionHeaderView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, SECTION_HEADER_HEIGHT)];
SectionInfo *sectionInfo = (self.headerInfoArray)[section];
sectionHeaderView.open = sectionInfo.open;
sectionInfo.headerView = sectionHeaderView;
sectionHeaderView.titleLabel.text = [NSString stringWithFormat:@"%@ (%lu)",sectionInfo.list.title, (unsigned long)[sectionInfo.list.objectsInList count]];
sectionHeaderView.section = section;
sectionHeaderView.delegate = self;
return sectionHeaderView;
}
You should implement heightForHeaderInSection:
and set the height for the header to a value > 0.