I use
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
customView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 24.0)];
headerLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 3, tableView.bounds.size.width, 18)];
headerLabel.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource: @"section" ofType: @"png"]]];
customView.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource: @"section" ofType: @"png"]]];
headerLabel.textColor = [UIColor whiteColor];
headerLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:15];
headerLabel.font = [UIFont boldSystemFontOfSize:15];
headerLabel.frame = CGRectMake(0.0, 0.0, 320.0, 24.0);
if(searching)
headerLabel.text = @" Search Results";
}
else {
if(section == 0)
headerLabel.text = @" Sponsored";
}
else {
headerLabel.text = @" Unsponsored";
}
}
if(searching)
headerLabel.text = @" Sök resultat";
}
else {
if(section == 0)
headerLabel.text = @" Sponsrade";
}
else {
headerLabel.text = @" Un Sponsrade";
}
}
[customView addSubview:headerLabel];
return customView;
[customView release];
}
in the header section in the table view, to split the table in two sections, when I look up and down the table view, the memory allocation increases very quickly, but instead of using the above code in the header section there is no memory allocation and the application works fine. But there is a need to use the above code in the header section, I cannot remove the code from the header, and I want to also reduce memory allocation. Is there any other way to solve the problem.
Thanks at Advance.
source
share