How to authorize columns in NSTableView or NSOutlineView based on view

What is required to support a column autoload query for a view- based table ? The docs are actually unclear on this issue and seem to be talking about cellular representations.

This is done by double-clicking on the column separator.

I can do this work by doing tableView:sizeToFitWidthOfColumn:for NSTableViewand outlineView:sizeToFitWidthOfColumn:for NSOutlineView, but the docs say it is only necessary for large tables. Is there a better way to do this?

- (CGFloat)tableView:(NSTableView*)tableView sizeToFitWidthOfColumn:(NSInteger)column {
  NSUInteger n = [self numberOfRowsInTableView:tableView];
  CGFloat w = 30;
  NSTableColumn* col = [[tableView tableColumns] objectAtIndex:column];
  for (int i=0; i<MIN(n, 100); ++i) {
    NSView* vw = [self tableView:tableView viewForTableColumn:col row:i];
    w = MAX(w, [vw frame].size.width);
  }
  return w;
}
+4
source share
1 answer

. , , framework, , -[NSTableView _sizeToFitWidthOfColumn:]. , , , , , , .

OS X 10.6 2009 . , , , , .

+2

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


All Articles