I have an UITableView where in the header part there are multiple headerSection available. The default height is 56. Now I want to change a particular headerSection height to 40 whenever I click on the particular section's button. the click triggers a method(sectionOpened:)
which helps to change the height. But at that time, the other headerSection's height should remain 56. How do I do that? My attempt so far:
should
float headerSectionHeightDefault;
- (void)viewDidLoad
{
[super viewDidLoad];
headerSectionHeightDefault=56;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return headerSectionHeightDefault;
}
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
headerView = [[UIView alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 640.0f, 0.0f)];
UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(15, 0, 300, 40)];
img.image = [UIImage imageNamed:@"menu_btn7.png"];
[headerView addSubview:img];
return headerView;
}
- (void) sectionOpened : (NSInteger) section
{
[menulistTable beginUpdates];
if(section==0)
{
headerSectionHeightDefault=40;
}
else
{
headerSectionHeightDefault=56;
}
[menulistTable endUpdates];
self.openSectionIndex = section;
}