ビューベースのテーブルビューを使用しています。各セルはNSView
自動レイアウト制約のある単純なものであり、セルにはいくつかのビューが含まれています。その主なものはNSTableView
(必須NSScrollView
にラップされ、次に単純にラップされていNSView
ます)です。
tableView:viewForTableColumn:row
デリゲートメソッドが呼び出されると、ビューの作成に使用しmakeViewWithIdentifier
ます。
次に、ビューを設定します。特に、セルの内部テーブルビューはデータソースを取得します。
ただし、ビューがリサイクルされているビューである場合、ログに次のよく知られたエラーが表示されます。
Unable to simultaneously satisfy constraints:
(
"<NSLayoutConstraint:0x10ab8a020 V:[NSView:0x100423720(132)]>",
"<NSLayoutConstraint:0x1004581e0 NSScrollView:0x1004c82c0.bottom == NSView:0x100423720.bottom>",
"<NSLayoutConstraint:0x100458340 V:|-(0)-[NSScrollView:0x1004c82c0] (Names: '|':NSView:0x100423720 )>",
"<NSAutoresizingMaskLayoutConstraint:0x10138d730 h=-&- v=-&- V:[NSClipView:0x1004ca010]-(220)-| (Names: '|':NSScrollView:0x1004c82c0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x10138d6d0 h=-&- v=-&- V:|-(0)-[NSClipView:0x1004ca010] (Names: '|':NSScrollView:0x1004c82c0 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1004581e0 NSScrollView:0x1004c82c0.bottom == NSView:0x100423720.bottom>
この場合、内部クリップビューの制約が220の高さに設定されていることに注意してください。これは、実際にはテーブルの以前の高さです。
私が何をしても、テーブルはその高さを更新しません。データソースの変更、呼び出しtile
、レイアウトの強制、制約の更新の強制、テーブルビューの削除と再追加などを試みましたが、何も役に立ちません。
translatesAutoresizingMaskIntoConstraints
奇妙なことに、私のすべてのビューで無効になっているため、そもそもレイアウトの制約があります。実際、tableView.constraints
ログにダンプすると、最初は制約がありませんが、突然、たくさんの奇妙な重複制約があります。
"<NSAutoresizingMaskLayoutConstraint:0x1013c2360 h=--& v=--& H:|-(-100)-[NSScroller:0x1030ea3c0] (Names: '|':ScrollViewWithoutScrolling:0x1030e8c80 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c23c0 h=--& v=--& H:[NSScroller:0x1030ea3c0(15)]>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c2420 h=--& v=--& V:|-(-100)-[NSScroller:0x1030ea3c0] (Names: '|':ScrollViewWithoutScrolling:0x1030e8c80 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c2290 h=--& v=--& V:[NSScroller:0x1030ea3c0(102)]>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c2de0 h=--& v=--& H:|-(-100)-[NSScroller:0x1030ea620] (Names: '|':ScrollViewWithoutScrolling:0x1030e8c80 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c2e50 h=--& v=--& H:[NSScroller:0x1030ea620(223)]>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c2eb0 h=--& v=--& V:|-(-100)-[NSScroller:0x1030ea620] (Names: '|':ScrollViewWithoutScrolling:0x1030e8c80 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c2f10 h=--& v=--& V:[NSScroller:0x1030ea620(15)]>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c4500 h=-&- v=-&- H:|-(0)-[NSClipView:0x1030ea880] (Names: '|':ScrollViewWithoutScrolling:0x1030e8c80 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c4570 h=-&- v=-&- H:[NSClipView:0x1030ea880]-(0)-| (Names: '|':ScrollViewWithoutScrolling:0x1030e8c80 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c45d0 h=-&- v=-&- V:|-(0)-[NSClipView:0x1030ea880] (Names: '|':ScrollViewWithoutScrolling:0x1030e8c80 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c4630 h=-&- v=-&- V:[NSClipView:0x1030ea880]-(110)-| (Names: '|':ScrollViewWithoutScrolling:0x1030e8c80 )>"
これは私にはバグのように見えます。何かがこれらの制約を作成しています(そしてそれを間違って行っています)が、それは私ではありません。何が起こるかを確認するために、それらを削除しようとしましたが、removeConstraint
削除しないか、constraints
再作成しています。
有効になっているビューは1つだけです。それはtranslatesAutoresizingMaskIntoConstraints
、セルビュー自体です。それは、私がそれを無効にすると、奇妙なことに、それが完全に空になるからです。
一般に、ビューベースのテーブルのセルビューの自動レイアウトは問題を引き起こしているようですが、それを機能させる方法があることを望んでいます。