views:

155

answers:

0

I am using a custom header view in my UITableView, but as soon as i begin scrolling down the header disappears instead of staying in place like with the default headers. And it's not scrolling off the screen either, just completely disappering. viewForHeaderInSection is still being called but the drawRect method of my custom header view isn't. What am I doing wrong? Here's some code...

My UITableView datasource...

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{   
    HeaderView* headerView = [[[HeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 40.0f)] autorelease];
    return headerView;
}

...and my custom header...

-(void)drawRect:(CGRect)rect
{
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetRGBFillColor(context, 115.0f, 125.0f, 133.0f, 0.5f);
    CGContextFillRect(context, CGRectMake(0.0f, 0.0f, 320.0f, 40.0f));
}