ダイナミックテーブルセルと自動レイアウトに関連する記事を3日間見てきましたが、それまでは動作していませんでした。AutolayoutとUITableAutomaticDimension(動的UILabel +複数のUIImageViews)を使用した動的高さテーブルセル
以下は、私が望むテーブルのセルです。ここでの主な問題は、ポストテキストとUIImagesのためのUILabelです。ここで
UI要素の階層です。
- Content View
+ ...
+ UILabel for text - dynamic height
+ UIView - image view container
* UIImageView
* UIImageView
* ....
ラベルは改行モードラップテキストと0 ラベルに設定ラインを持っており、コンテナビューは、上部、下部、先頭と末尾の制約があります。 ImageViewsは実行時に追加され、上端、下端、下端、および高さの制約に制約があります。 最初のイメージビューにはコンテナビューに対する上限制約があり、最後のイメージビューにはコンテナビューに対する下限制約があり、他のイメージビューには上位イメージビューに対する上限制約があります。テーブルが最初にロードされる
(細胞が異なる画像数を持っている)、それは正常に見えるが、私は上下にスクロール、制約がいくつかの細胞に破壊されたときに画像を細胞内にオーバーラップしています。ここで
はエラー出力です:
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.
"<NSLayoutConstraint:0x17428aaf0 V:|-(0)-[UIImageView:0x14be77ed0] (active, names: '|':UIView:0x14be75b20)>",
"<NSLayoutConstraint:0x17428a6e0 UIImageView:0x14be77ed0.height == 160 (active)>",
"<NSLayoutConstraint:0x17428acd0 UIImageView:0x14be77ed0.bottom == UIView:0x14be75b20.bottom (active)>",
"<NSLayoutConstraint:0x174289650 V:|-(0)-[UIImageView:0x14be43ce0] (active, names: '|':UIView:0x14be75b20)>",
"<NSLayoutConstraint:0x17428bb80 UIImageView:0x14be43ce0.height == 160 (active)>",
"<NSLayoutConstraint:0x17428be50 V:[UIImageView:0x14be43ce0]-(10)-[UIImageView:0x14be74b10] (active)>",
"<NSLayoutConstraint:0x17428bfe0 UIImageView:0x14be74b10.height == 160 (active)>",
"<NSLayoutConstraint:0x17428c080 UIImageView:0x14be74b10.bottom == UIView:0x14be75b20.bottom (active)>"
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x17428be50 V:[UIImageView:0x14be43ce0]-(10)-[UIImageView:0x14be74b10] (active)>
この問題で私を助けてください。ありがとうございました。
もっとコードやストーリーボードやセルを表示してください。 – anhtu
1つのセルに表示する必要がある画像の最大数 –
@HimanshuMoradiya、無制限です。ユーザーは必要な画像を添付することができます。 –