ここで少し空白に主演されましたが、おそらく長すぎるので、ここで投稿しようとしています。ここでUITableViewHeaderFooterViewの制約はUIViewAlertForUnsatisfiableConstraintsになります
は、私が見ていますエラーです:
2017-11-02 22:43:23.972361-0700 TableViewCellHeaderViewLayoutTest[88247:17250641] [LayoutConstraints] 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:0x60c000092930 V:|-(12)-[UILabel:0x7fd450c0eb80'Header 1'] (active, names: '|':_UITableViewHeaderFooterContentView:0x7fd450c0f290)>",
"<NSLayoutConstraint:0x60c0000927f0 UILabel:0x7fd450c0eb80'Header 1'.bottom == _UITableViewHeaderFooterContentView:0x7fd450c0f290.bottom - 6 (active)>",
"<NSLayoutConstraint:0x60c000092ac0 'UIView-Encapsulated-Layout-Height' _UITableViewHeaderFooterContentView:0x7fd450c0f290.height == 17.5 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x60c0000927f0 UILabel:0x7fd450c0eb80'Header 1'.bottom == _UITableViewHeaderFooterContentView:0x7fd450c0f290.bottom - 6 (active)>
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.
それは私のUITableViewHeaderFooterView
サブクラスの超簡単な実装です:私に際立っ
class TableViewSectionHeaderView: UITableViewHeaderFooterView {
let titleLabel = UILabel()
override init(reuseIdentifier: String?) {
super.init(reuseIdentifier: reuseIdentifier)
contentView.backgroundColor = .gray
titleLabel.backgroundColor = contentView.backgroundColor
titleLabel.font = UIFont.preferredFont(forTextStyle: .footnote)
contentView.addSubview(titleLabel)
titleLabel.translatesAutoresizingMaskIntoConstraints = false
titleLabel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 12).isActive = true
titleLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 6).isActive = true
titleLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -6).isActive = true
titleLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -6).isActive = true
}
}
事は、この制約である:
"<NSLayoutConstraint:0x60c000092ac0 'UIView-Encapsulated-Layout-Height' _UITableViewHeaderFooterContentView:0x7fd450c0f290.height == 17.5 (active)>"
私が調べると、priority
の1000
、なぜ私自身の制約が失敗するように見えるかを説明します。
すべてが視覚的にうまくいきますが、私はその警告を心配しています。私は間違って何をしていますか?
ラベルの高さが動的テキストによって変更された場合にヘッダービューを拡大させたいと仮定して、高さを自動的に設定することによって、headerViewのサイズを変更できるようにする必要があると思います。 – Daniel
OMG @Danielありがとう!私は狂っていた。私が設定する必要があったのは 'sectionHeaderHeight'から' UITableViewAutomaticDimension'と 'estimatedSectionHeaderHeight'でした。 *ヘッドデスク* – runmad
あなたが答えとして追加するなら、私は受け入れることができます☺ – runmad