0

With Xcode 9.2, I'm working on a macOS project with two different windows.

In one of the windows, I have a view-based tableView with one column, the header of the column is regularly shown. In another window, there is a similar tableView, but the header (which is visible in IB), at runtime is not shown.

I compare the properties of the two tableViews in IB but they are the same. Also, the Header checkbox in the Table View section (which has a role in this UI element, as described in a reply to this question Hiding NSTableView header?) is checked.

What could the problem depend on?

TableView Properties pane:

TableView Properties pane

Interface Builder:

Interface Builder

Runtime:

Runtime

Edited:

class EditTasksController: NSViewController, NSTableViewDelegate, NSTableViewDataSource {

  override func viewDidLoad() {
     super.viewDidLoad()

     self.actionsListTableView.dataSource = self
     self.actionsListTableView.delegate = self

     actionsListTableView.backgroundColor = NSColor.clear
     actionsListTableView.headerView = nil

     func tableViewSelectionDidChange(_ notification: Notification) {

     ...
Cue
  • 2,952
  • 3
  • 33
  • 54
  • What does the code look like? Are you modifying / messing with the header in e.g. `viewForTableColumn:`? – TheNextman Mar 08 '18 at 14:25
  • @TheNextman, thank you for the comment, I edited the question including the code – Cue Mar 08 '18 at 18:22
  • 1
    Use Xcode's view debugger to inspect the view hierarchy at run time. It will show you locations, sizes, and z-order of views. – Phillip Mills Mar 08 '18 at 18:42
  • `actionsListTableView.headerView = nil`. Remove this line. – TheNextman Mar 08 '18 at 19:27
  • 1
    Thank you for your comment about Xcode's view debugger Phillip Mills, I will definitely use this technique. @TheNextman it worked, please answer the question so I can accept it. – Cue Mar 08 '18 at 20:25

1 Answers1

1

This line:

actionsListTableView.headerView = nil

Removes the header from the table. Remove that line of code, and the header will be visible.

TheNextman
  • 12,428
  • 2
  • 36
  • 75