I'm trying to size the rows of a NSTableView to exactly 9 rows fit. I've tried [menuTableView setRowHeight:floor(menuRect.size.height / 9)];
and I've tried [menuTableView setRowHeight:(menuRect.size.height / 9)];
and [menuTableView setRowHeight:ceil(menuRect.size.height / 9)];
but all of them have the same issue, if I've selected row 0 then row 9 is clipped at the bottom and if I select row 9 then row 0 is clipped at the top.
How can I set up a NSTableView to show 9 full rows so no matter what there is never a partial row visible?
Thanks,
edit: Yes menuRect is the frame for the menuTableView
edit:
Below is the full method I use to position the NSTableView and set the row height I've tried to remove any rounding issues with the use of the rowHeight
variable. You can see with the attached screen shot that the last row isn't fully displayed
- (void) updateGUIPositions
{
NSRect screenRect = [self frame];
NSRect menuRect;
// Set the menu location on screen
NSInteger spacer = screenRect.size.width / 9;
menuRect.size.width = floor(screenRect.size.width - (spacer * 3)) / 2;
menuRect.size.height = ceil(screenRect.size.height - (spacer * 2));
NSInteger rowHeight = menuRect.size.height / 9;
menuRect.size.height = rowHeight * 9;
menuRect.origin.x = menuRect.size.width + (spacer * 2);
menuRect.origin.y = spacer;
[menuScrollView setFrame:menuRect];
// Setup the row height
[menuTableView setRowHeight:rowHeight];
}