ViewForHeaderInSection disappears when scrolling

I use my own title view in my UITableView, but as soon as I start scrolling through the title, it disappears, instead of remaining in place, as with the default headers. And it does not scroll from the screen, it just disappears completely. viewForHeaderInSection is still being called, but the drawRect method of my custom header is not. What am I doing wrong? Here is the 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 title ...

-(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));
}
+3
source share
1 answer

, , , ivar / , , . , , ( ). , .

+2

Source: https://habr.com/ru/post/1742610/


All Articles