2017-11-07 11 views
0

私のUITableViewCellの行が表示されたときに、それらの高さは44となっています。間違いなくその行を行うべきではありません。下の警告のように、悪い制約についてはわかるように、パスの上から下まで全体を制約しました。私のUITableViewCell行が高さ44に強制されるのはなぜですか?

私の$ ballIsSquare $ height/width制約が嫌いという事実を無視しても、高さが44以上のセルがあるはずです。ほぼ円形のボールが表示されています。これは高さがほぼ55の高さです($ ballWidth $を55と表示しています)。しかし、ボールの上にくるように制約されている日付ラベルは表示されません。ビューコントローラは、この100の推定された行の高さを指定し、rowHeightのがUITableViewAutomaticDimensionに設定されている?

ほど小さくなるように強制。

I「はUISVアライメント」とUISV-キャンバス接続を考えます使用されているUIStackViewの制約です($ ballsBottom $はボールUIStackViewを参照しています)

UIView-Encapsulated-Layout-Heightは、本当の問題であることを私に教えてください。

"<NSLayoutConstraint:0x60400008d070 '$ballIsSquare$' DidIWin.BallView:0x7f8525a3fec0.height == DidIWin.BallView:0x7f8525a3fec0.width (active)>", 
    "<NSLayoutConstraint:0x604000091ad0 '$ballsBottom$' DidIWin.Balls:0x7f8525a3e890.bottom == UILayoutGuide:0x6040001a6c80'UIViewSafeAreaLayoutGuide'.bottom - 10 (active)>", 
    "<NSLayoutConstraint:0x604000086c70 '$ballWidth$' DidIWin.BallView:0x7f8525a3fec0.width == 55 (active)>", 
    "<NSLayoutConstraint:0x6040000928e0 '$largeDateBottom$' UILabel:0x7f8525a44510'10/4/17'.bottom == DidIWin.Balls:0x7f8525a3e890.top + 10 (active)>", 
    "<NSLayoutConstraint:0x604000092840 '$largeDateTop$' UILabel:0x7f8525a44510'10/4/17'.top == UILayoutGuide:0x6040001a6c80'UIViewSafeAreaLayoutGuide'.top + 10 (active)>", 
    "<NSLayoutConstraint:0x604000092020 'UISV-alignment' DidIWin.BallView:0x7f8525a3ead0.bottom == DidIWin.BallView:0x7f8525a3fec0.bottom (active)>", 
    "<NSLayoutConstraint:0x604000091f30 'UISV-alignment' DidIWin.BallView:0x7f8525a3ead0.top == DidIWin.BallView:0x7f8525a3fec0.top (active)>", 
    "<NSLayoutConstraint:0x60400008c670 'UISV-canvas-connection' DidIWin.Balls:0x7f8525a3e890.top == DidIWin.BallView:0x7f8525a3ead0.top (active)>", 
    "<NSLayoutConstraint:0x604000091c60 'UISV-canvas-connection' V:[DidIWin.BallView:0x7f8525a3ead0]-(0)-| (active, names: '|':DidIWin.Balls:0x7f8525a3e890)>", 
    "<NSLayoutConstraint:0x604000091da0 'UIView-Encapsulated-Layout-Height' DidIWin.FailureDetailCell:0x7f8526047200'failure'.height == 44 (active)>", 
    "<NSLayoutConstraint:0x604000091940 'UIViewSafeAreaLayoutGuide-bottom' V:[UILayoutGuide:0x6040001a6c80'UIViewSafeAreaLayoutGuide']-(0)-| (active, names: '|':DidIWin.FailureDetailCell:0x7f8526047200'failure')>", 
    "<NSLayoutConstraint:0x6040000918a0 'UIViewSafeAreaLayoutGuide-top' V:|-(0)-[UILayoutGuide:0x6040001a6c80'UIViewSafeAreaLayoutGuide'] (active, names: '|':DidIWin.FailureDetailCell:0x7f8526047200'failure')>" 

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x60400008d070 '$ballIsSquare$' DidIWin.BallView:0x7f8525a3fec0.height == DidIWin.BallView:0x7f8525a3fec0.width (active)> 

答えて

-1
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat 
{ 
    if(indexPath.section == 0){ 
     return 50 
    }else{ 
     return 120 
    } 
} 

あなたのビューコントローラに

をこのデリゲートメソッドを追加するか、あなたは

+0

自動ディメンションに

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return UITableViewAutomaticDimension } 

を使用することができません、それは私が欲しいものではありません。静的なサイズのセルではありません。設定されている制約に基づいて、動的なサイズです。 – Gargoyle

+0

編集した回答を確認してください –

+0

表示するデリゲートメソッドは役に立ちません。高さメソッドはデリゲートとして実際には必要ありません。それは既にテーブルそのものに設定されています。また、私は私の質問の3番目の段落にそれがすでに設定されていると述べました。質問は、私が高さを44に強制している理由を質問しています。 – Gargoyle

関連する問題