I have a view-based NSTableView with a graphical representation of an NSTableCellView table graphically through an interface constructor in the latest version of Xcode 10.8.2.
When I call -reloadData on an NSTableView, it crashes:
Unable to simultaneously satisfy constraints: ( "<NSAutoresizingMaskLayoutConstraint:0x105cb8bf0 h=--& v=--& V:[NSTableRowView:0x105ca7020(0)]>", "<NSAutoresizingMaskLayoutConstraint:0x10596aa30 h=--& v=-&- V:[GroupTableRowView]-(2)-| (Names: GroupTableRowView:0x100185860, '|':NSTableRowView:0x105ca7020 )>", "<NSAutoresizingMaskLayoutConstraint:0x1058d9770 h=--& v=-&- V:|-(1)-[GroupTableRowView] (Names: GroupTableRowView:0x100185860, '|':NSTableRowView:0x105ca7020 )>" ) Will attempt to recover by breaking constraint <NSAutoresizingMaskLayoutConstraint:0x10596aa30 h=--& v=-&- V:[GroupTableRowView]-(2)-| (Names: GroupTableRowView:0x100185860, '|':NSTableRowView:0x105ca7020 )>
I cannot turn off the translation of the auto-change mask in any of the views, since their limitations are controlled by NSTableView. Clearly, the restrictions are inconsistent because the NSTableRowView cannot have a height of 0, but it still satisfies the two other restrictions in the GroupTableRowView that indicate mandatory padding between the superview (row view?). I am not sure how to solve this, any ideas would be appreciated. Thanks!
Update : I found a workaround. The problem is that for some reason the NSTableRowView is sending the frame size {0, 0} when calling -reloadData in the table view. I tried -setFrameSize: in a subclass of NSTableRowView and passed the message only to the responder chain when the size is not {0,0} .
- (void)setFrameSize:(NSSize)newSize { if (!NSEqualSizes(newSize, NSZeroSize)) [super setFrameSize:newSize]; }
To use a subclass, implement the NSTableViewDelegate method - tableView: rowViewForRow: to return an instance of a custom subclass.
- (NSTableRowView *)tableView:(NSTableView *)tableView rowViewForRow:(NSInteger)row { id rowView = [[GroupTableRowView alloc] init];
If the table view is completely constructed in IB, you can simply drag and drop the new NSView into the table view and set its own class to a subclass of NSTableRowView and change its UI element identifier to NSTableViewRowViewKey