NSTableHeaderView Resizing Makes Table Rows Move Down

645 views Asked by At

I've created a subclass of NSScrollView which is set as the class of a scroll view with table view in IB. I increased the height of the table's header view and added a label to act as the title for the table view. The problem is that the table rows start below the column headers by an amount that is equal to the amount that I made the header view taller (so the column titles appear in the middle of the new taller header view).

enter image description here

I've tried changing the origin or size of the table, the table's clip view, the header view, and its clip view -- none of this changes anything except for the size of the header view. This is the code I used to make the custom header view:

-(void)awakeFromNib {
    //self is a subclass of NSScrollView enclosing an NSTableView
    NSClipView *tableClip = [self.subviews objectAtIndex:0];
    NSClipView *headerClip = [self.subviews objectAtIndex:3];
    NSTableHeaderView *header = [[[self.subviews objectAtIndex:3] subviews]lastObject];
    NSTableView *table = [[[self.subviews objectAtIndex:0] subviews]lastObject];
    NSLog(@"%@  %@  %@  %@",tableClip,headerClip,header,table);

    [header setFrameSize:NSMakeSize(header.frame.size.width, header.frame.size.height+60)];//HeaderView Frame
    NSTextField *titleLabel = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 5, header.frame.size.width,22)];
    titleLabel.selectable = NO;
    titleLabel.font = [NSFont systemFontOfSize:16];
    titleLabel.alignment = NSCenterTextAlignment;
    titleLabel.bordered = NO;
    titleLabel.stringValue = @"This is my title";
    [header addSubview:titleLabel];
}
0

There are 0 answers