NSTableView automatically adjust height to fit cell view

Reference: Using auto-layout to calculate table cell height In ‘Using auto-layout to calculate table cell height’, it’s introduced how to use auto-layout to update table view’s (UITableView) cell height with Objective-C language. However there is different at NSTableView. Here I will introduce to do similar thing at NSTableView with Swift language. Remember one thing post ‘Using auto-layout to calculate table cell height’ has warned that this method is not that efficient, figure out the way make it more efficient yourself.

Make text table view(NSTableView) auto resize

To make a iMessage-like chat table view, there is several steps to follow: Text field should be able to adjust its size automatically. Image view of bubble should adjust automatically relative to text field. Table view’s row should be fitted into the row cell’s subview, which include text field and image view. Let scroller auto scroll to bottum. Here I use View-based NSTableView to make these: Table view settings There is some import constraints to make the three components, NSImageView, NSTextField, NSTableViewCell, keep corresponded size, which is showed below:

The method resetTransform of SCNPhysicsBody

According to the SceneKit document, the function of resetTransform is: Updates the position and orientation of a body in the physics simulation to match that of the node to which the body is attached. Through experiment, I found this is little special. If you do this: var node = SCNNode(geomentry: SCNBox()) node.position = SCNVector3(0, 1, 0) node.rotation = SCNVector4(1, 0, 0, CGFloat(M_PI)/2) node.physicsBody = SCNPhysicsBody(type: .Dynamic, nil) scene.rootNode.addChildNode(node) If you get the position and rotation of node.