1
votes

I have an NSTableView (View type, not Cell type) which is resulting in text with "..." at the end. When I resize the columns, the "..." doesn't go away, indicating that the size is being set somewhere else... but I'm not sure where.

Here is what the table looks like: enter image description here

When I make it bigger, the text is still truncated:

enter image description here

If I take out the ".ByClipping", I get this:

enter image description here

Here is the code that makes the cell:

func tableView(tableView: NSTableView, viewForTableColumn tableColumn: NSTableColumn?, row: Int) -> NSView? {
    let identifier = tableColumn!.identifier
    let networkName = displayedNetworks[row]
    let networkVals = model.networks[networkName]!
    if let val: AnyObject = networkVals[identifier]  {
        var obj = tableView.makeViewWithIdentifier(identifier, owner:self)
        if (obj==nil) {
            // No existing cell to reuse, so make a new one
            obj = NSTableCellView(frame:NSMakeRect(0,0,400,400))
            obj!.identifier = identifier
        }
        let cellView = obj as! NSTableCellView
        if let d = val as? NSDate {
            let formatter = NSDateFormatter()
            formatter.dateStyle = NSDateFormatterStyle.ShortStyle
            formatter.timeStyle = .ShortStyle
            cellView.textField!.stringValue = formatter.stringFromDate(d)+"****"
            cellView.textField!.lineBreakMode = .ByClipping
        }
        else {
            cellView.textField!.stringValue = "\(val)"
        }
        return cellView
    }
    return nil 

}

Something is wrong, but I can't figure it out. I thought that resizing the column resized the contained cells. Mine aren't. This is only happening with the cells that are displaying dates. What should I do?

1
Did you apply autolayout constraints to textfield?Daniyar

1 Answers

3
votes

Example you can select you Table View Cell in IB and then click that button "Resolve Auto Layuout Issues" which is just under pop over bottom left corner and the "Add Missing Constraints".

enter image description here