Finally, I solved the problem. I created an NSView (called documentContentView on it), added my NSTableView as a subtask of this DocumentContentView, after which I added documentContentView to the scrollview of documentView:
NSTableView *docView = (NSTableView *)self.scrollView.documentView; id newClipView = [[CustomClipView alloc] initWithFrame:[self.scrollView.contentView frame]]; [self.scrollView setContentView:(NSClipView *)newClipView]; [newClipView setDrawsBackground:NO]; NSView *documentContentView = [[NSView alloc] initWithFrame:docView.bounds]; docView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; [documentContentView addSubview:docView]; [self.scrollView setDocumentView:documentContentView]; [self.scrollView setDrawsBackground:NO];
I created my custom NSClipView called CustomClipView (based on this article http://www.cocoadev.com/index.pl?CenteringInsideNSScrollView ), and this subclass sets the start of documentContentView when the window changes. I also subclassed my desktop and in the -reloadData method I can resize the documentContentView when its change in the table has changed.
vbali source share