4

I have two NSTableView's in my app and the user can drag and drop items from table A to table B. When dragging an item to table B Xcode gives me the following layout warning message:

Layout still needs update after calling -[NSTableRowView layout]. NSTableRowView or one of its superclasses may have overridden -layout without calling super. Or, something may have dirtied layout in the middle of updating it. Both are programming errors in Cocoa Autolayout. The former is pretty likely to arise if some pre-Cocoa Autolayout class had a method called layout, but it should be fixed.

This ever only happens when items are dragged to table B. I have otherwise no auto-layout warnings in IB and everything in the layout looks like being set up correctly. Does somebody know what the above message is trying to tell me? The tables are using standard Cocoa classes (not sub-classed).

BadmintonCat
  • 9,416
  • 14
  • 78
  • 129

2 Answers2

3

I fixed it (or rather worked around it) by having the drop operation type not being allowed except for NSTableViewDropOperation.Above. Before a user could drop them onto other rows, not just between rows. But I want them to be only be allowed to be dropped between rows so that's fine with me. Here's the code that fixed it:

func tableView(aTableView:NSTableView, validateDrop info:NSDraggingInfo, proposedRow row:Int, proposedDropOperation operation:NSTableViewDropOperation) -> NSDragOperation
{
    if (operation == .Above) { return .Move; }
    return .None;
}
BadmintonCat
  • 9,416
  • 14
  • 78
  • 129
1

In my case the warning was slightly different.

Layout still needs update after calling -[NSView layout]. NSView or one of its superclasses may have overridden -layout without calling super. Or, something may have dirtied layout in the middle of updating it. Both are programming errors in Cocoa Autolayout. The former is pretty likely to arise if some pre-Cocoa Autolayout class had a method called layout, but it should be fixed.

Different class NSView.

Anyway in my case, I could fix this by setting translatesAutoresizingMaskIntoConstraints == false of a NSScrollView.

For the record, autoresizingMask and autoresizesSubviews don't need to be touched at all.

The warning simply means that I have to set the property manually, otherwise it will produce wrong constraints. But figuring out the problematic object was very hard. I had to iterate all view nodes to check the property state.

eonil
  • 83,476
  • 81
  • 317
  • 516