viewForHeaderInSection not getting called on reloadData

277 Views Asked by At

viewForHeaderInSection is not getting called on reloadData. How ever it is getting called first time when the view is loaded. Very strange. Any help?I've implemented the below delegate methods.

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 0;
}

-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection:(NSInteger)section
{
    return 1500.0f;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return  UITableViewAutomaticDimension;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {}
1

There are 1 best solutions below

3
On

Your heightForHeaderInSection probably return 0 because UITableViewAutomaticDimension does not work. In order to make UITableViewAutomaticDimension work you have to set all left, right, bottom, and top constraints relative to cell container view.