0

I have an NSTableView with 2 columns where the cells are plain NSTableCellViews and the text of its text field is set from a dictionary.

It is all created in IB where I just drag/dropped a Table view into my app.

My problem is that the cell text is truncated regardless of the width of the column. It does not matter if I set the column width programatically or if I resize it during runtime.

Here is my viewForTableColumn:

  func tableView(tableView: NSTableView, viewForTableColumn tableColumn: NSTableColumn?, row: Int) -> NSView?
  {
    let cell : NSTableCellView = tableView.makeViewWithIdentifier(tableColumn!.identifier, owner: self) as! NSTableCellView
    cell.textField!.stringValue = dataArray[row].objectForKey(tableColumn!.identifier)! as! String
    return cell
  }

Here you can see the result (I'm listing installed apps along with their current version)

This is the output .

As you can see some of the rows with longer names are truncated.

Any pointers on how I can give the text fields the width they need to display all its content ? Either in Xcode/IB or programatically. This is my first OSX app so talk to me like I'm a Windows user ... ;)

4

1 回答 1

1

你可以使用约束。首先选择您的文本字段,然后在工具提示显示“解决自动布局问题”的右侧按下那个小按钮。然后选择添加缺少的约束。

在此处输入图像描述

于 2016-01-13T15:10:07.243 回答