How to get the height of an NSTableCellView that uses autostart

I have a view based NSTableView . I positioned textField and other elements in NSTableCellView in Interface Builder with autostart. How to get height for a cell based on its autodetection parameters?

This answer is the closest I found to what I'm looking for, but it is written for iOS, and the systemLayoutSizeFittingSize method systemLayoutSizeFittingSize not exist on NSView .

+8
autolayout nsautolayout nstableview macos nstablecellview
source share
1 answer

You can put views inside your table cell view in a separate NSView (allow this contentView ). Set the automatic layout restrictions for the contentView so that it matches its parent view on the left (leading), top and right (trailing). Make sure the contentView sub- contentView resize their parent view. Create an IBOutlet in this view in an NSTableCellView subclass. To calculate the height, call fittingSize on the contentView , which should get the minimum size of your subzones based on constraints.

+5
source share

All Articles