Reputation: 10959
I had two UITableView in my project and I am giving custom header to one table using the method:
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if(tableView.tag == 3)
{
SectionInfo *array = [self.sectionInfoArray objectAtIndex:section];
if (!array.sectionView)
{
NSString *title = array.groupdeck.groupTitle;
array.sectionView = [[SectionView alloc] initWithFrame:CGRectMake(0, 0, tblData.bounds.size.width, 45) WithTitle:title Section:section delegate:self];
}
return array.sectionView;
}
else{
return 0;
}
return 0;
}
It is giving the header to the table with the tag 3 like:
But it is giving the default header to other table also even return 0
else condition like:
What am I missing?
Upvotes: 0
Views: 99
Reputation: 7733
With Reference to written in Apple Documentation
// custom view for header. will be adjusted to default or specified header height
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;
It is displaying the default header which has height of 22 for grouped table and 10 for nongrouped table.
Also if the height of your view which you want to display in UITableView
is more than above values then you also have to use the UITableView
Delegate method
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
Upvotes: 0
Reputation: 4500
Try :
otherTable.sectionHeaderHeight = 0.0;
You don't have to do anything else.
Or:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if(tableView.tag == 3)
{
//Required height.
}
else
{
return 0.0;
}
}
Upvotes: 2
Reputation: 438
It might be defaulting to the default header because you returned a 0
. Try returning nil
instead.
From: tableView:viewForHeaderInSection: default value?
Upvotes: 2