0

I am using the following code to support NSTableCellView height grow while editing the cell. The cell contains custom NSTextField where I override intrinsicContentSize:

override var intrinsicContentSize: NSSize {
    
    if !isEditable {
        return super.intrinsicContentSize
    }
    
    if let txt = self.window?.fieldEditor(false, for: self) as? NSTextView {
        
        if let container = txt.textContainer {

            if let layoutManager = container.layoutManager {
                layoutManager.ensureLayout(for: container)
                let size = layoutManager.usedRect(for: container).size

                return NSMakeSize(NSView.noIntrinsicMetric, size.height)  
            }
        }
    }
    
    return super.intrinsicContentSize
    
}

container.layoutManager always returns nil in Big Sur, and it cause the cell to stay a single line while editing, while it is not nil in Catalina and the cell grows as expected.

Would appreciate any clue in fixing this issue.

J.Doe
  • 318
  • 2
  • 13
  • I was able to solve the problem by using the solution below https://stackoverflow.com/a/53125958/6229293 – J.Doe Jun 18 '21 at 00:44

0 Answers0