Can anyone help me figure out how to add and image to the header view? The code I tried using doesn't work. Below is what I have so far.
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{
UITableViewHeaderFooterView *headerView = (UITableViewHeaderFooterView*)view;
if (headerView != nil)
{
headerView.contentView.backgroundColor = [UIColor greenColor];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(200.0f, 0.0f, 100.0f, 25.0f)];
*imageView.image = [UIImageView = image.png];* //This line doesn't work.
[headerView.contentView addSubview:imageView];
UILabel *mainLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 25.0f)];
mainLabel.text = [sectionTitles objectAtIndex:section];
mainLabel.backgroundColor = [UIColor redColor];
[headerView.contentView addSubview:mainLabel];
UILabel *secondLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 26.0f, 150.0f, 20.0f)];
secondLabel.text = @"Second Label Text";
secondLabel.backgroundColor = [UIColor yellowColor];
[headerView.contentView addSubview:secondLabel];
}
}