The cells themselves appear with the amount of items in the items
array (I can select them), but they don't have the title assigned to them.
...
let items: Array<String>? = // contains only strings (also without control characters)
@IBOutlet weak var tableView: NSTableView!
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.delegate = self
self.tableView.dataSource = self
}
func numberOfRows(in tableView: NSTableView) -> Int {
return self.items!.count
}
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
if let cell = tableView.makeView(withIdentifier: tableColumn!.identifier, owner: self) as? NSTableCellView {
cell.textField?.stringValue = self.items![row]
return cell
}
return nil
}
...
For some reason I had to select the table view on the view hierarchy and set the content mode to cell based and back to view based. Now it works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.