私のアプリでは、固定の比率(16x9)のカスタムtableViewCellがあります。これを実現するために、私はセルにビューを配置し、それを親ビューに固定しました(私はインターフェイスビルダーでそれを行いました:V/H:|-[innerView]-|
)。 また、比率制約を付けました。iOS 9でUITableViewAutomaticDimensionが正しく機能しない
私のtableViewControllerでは、UITableViewAutomaticDimension
を表のセルの高さとして使用しています。
推定される行の高さは180ピクセルです(見てのとおり、セルが320ピクセルの幅のディスプレイに表示される正確なサイズです)。
すべてが正常に動作し、完璧に見えるが、私はまだ8.4のために配備するんだけど、iOSの9とデバイス上でプロジェクトを実行しているとき、私は自動レイアウトの警告のトンを取得しています。
警告自体は絶対に正しいです。私が望まない2つの制約があります - これらはiOSが独自に追加したものです。
2015-09-29 11:24:57.771 app[1039:324736] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x147d3e0d0 UIView:0x14901ff70.height == 0.5625*UIView:0x14901ff70.width>",
"<NSLayoutConstraint:0x147dd0210 H:|-(0)-[UIView:0x14901ff70] (Names: '|':UITableViewCellContentView:0x14901f960)>",
"<NSLayoutConstraint:0x147deeca0 V:|-(0)-[UIView:0x14901ff70] (Names: '|':UITableViewCellContentView:0x14901f960)>",
"<NSLayoutConstraint:0x149053c30 V:[UIView:0x14901ff70]-(0)-| (Names: '|':UITableViewCellContentView:0x14901f960)>",
"<NSLayoutConstraint:0x147dbc2b0 H:[UIView:0x14901ff70]-(0)-| (Names: '|':UITableViewCellContentView:0x14901f960)>",
"<NSLayoutConstraint:0x149070800 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x14901f960(179.5)]>",
"<NSLayoutConstraint:0x1490707b0 'UIView-Encapsulated-Layout-Width' H:[UITableViewCellContentView:0x14901f960(320)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x147d3e0d0 UIView:0x14901ff70.height == 0.5625*UIView:0x14901ff70.width>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
私がここで見るのは、iOSが何とか魔法のように減じた欠けている0.5ピクセルだけです。
私がここに見るのは、iOSが何とか魔法のために減算した0.5ピクセルが欠けていることだけです。この情報はどこですか? – BangOperator
@somexyzログに記録された制約を読んでください: 'V:[UITableViewCellContentView:0x14da0ff60(179.5)]' –