UITableView Section Headers Drawing Above Front Subview
        Posted  
        
            by hadronzoo
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by hadronzoo
        
        
        
        Published on 2010-03-16T19:59:53Z
        Indexed on 
            2010/03/16
            20:01 UTC
        
        
        Read the original article
        Hit count: 406
        
I have a UITableView whose data have sections. I display an overlay view on top of tableView that dims it when searching:
- (UIView *)blackOverlay {
if (!blackOverlay) {
    blackOverlay = [[UIView alloc] initWithFrame:[self overlayFrame]];
    blackOverlay.alpha = 0.75;
    blackOverlay.backgroundColor = UIColor.blackColor;
    [tableView insertSubview:blackOverlay aboveSubview:self.parentViewController.view];
}
return blackOverlay;
}
This works perfectly as long as tableView does not contain sections. When tableView does contain sections and the tableView updates (such as when the view reappears after popping a view off of the navigation controller stack), the section headers are rendered above blackOverlay. This leaves tableView dimmed except for the section headers. I've tried calling [tableView bringSubviewToFront:self.blackOverlay] from within viewWillAppear:, but I get the same behavior.
My current work-around is returning nil for tableView section headers while the overlay is present, but this leaves whitespace gaps in the overlaid tableView where the section headers were previously.
How can I insure that tableView section headers are never drawn above blackOverlay? Or, is it possible to create a view in front of tableView from within a UITableViewController subclass that is not a subview of tableView?
© Stack Overflow or respective owner