r4id4
r4id4

Reputation: 6077

OSX - Remove empty cells from NSTableView

I have an NSTableView which I fill correctly with some content.
The problem is that when I run the app the empty cells stays visible and squeezed to the default size.
I'd like to get rid of them, but I cannot find a solution for OSX (a Swift solution would be appreciated)

enter image description here

The red colored area shows the empty cells in the UI, while the first 2 rows are filled with content.
Thanks

EDIT:

func numberOfRows(in tableView: NSTableView) -> Int {
        return array.count
    }

Upvotes: 2

Views: 472

Answers (1)

imthath
imthath

Reputation: 1688

An easy solution is to subclass / extend the TableView and override the drawGrid method. This will work well if you have only one column, as you have asked.
But if you have multiple columns, all the vertical grid lines will be gone as well.

class MyTableView: NSTableView {
   override func drawGrid(inClipRect clipRect: NSRect) {
    // Do nothing.
   }    
}

Upvotes: 1

Related Questions