Я пытаюсь получить минимальную высоту ячейки для ячейки tableView.Это работает, но выдает миллиард предупреждений в консоль отладчика XCode.
Вопрос 1 : Почему?
Вопрос 2 : Какизбавиться от этих предупреждений при реализации минимальной высоты ячейки?
2018-11-16 19:18:13.080131+0100 Test[46195:5492055] [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:0x600003a91450 V:[UILabel:0x7fa4f2e05470'One ']-(0)-| (active, names: '|':UITableViewCellContentView:0x7fa4f2e17f70 )>",
"<NSLayoutConstraint:0x600003a91310 V:|-(0)-[UILabel:0x7fa4f2e05470'One '] (active, names: '|':UITableViewCellContentView:0x7fa4f2e17f70 )>",
"<NSLayoutConstraint:0x600003a911d0 UILabel:0x7fa4f2e05470'One '.height >= 44 (active)>",
"<NSLayoutConstraint:0x600003a8dbd0 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x7fa4f2e17f70.height == 44 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600003a911d0 UILabel:0x7fa4f2e05470'One '.height >= 44 (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2018-11-16 19:18:13.081005+0100 Test[46195:5492055] [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:0x600003a953b0 V:[UILabel:0x7fa4f2c018d0'Three ']-(0)-| (active, names: '|':UITableViewCellContentView:0x7fa4f2c06510 )>",
"<NSLayoutConstraint:0x600003a95450 V:|-(0)-[UILabel:0x7fa4f2c018d0'Three '] (active, names: '|':UITableViewCellContentView:0x7fa4f2c06510 )>",
"<NSLayoutConstraint:0x600003a94be0 UILabel:0x7fa4f2c018d0'Three '.height >= 44 (active)>",
"<NSLayoutConstraint:0x600003a95cc0 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x7fa4f2c06510.height == 44 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600003a94be0 UILabel:0x7fa4f2c018d0'Three '.height >= 44 (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
Это можно просто воспроизвести с помощью этой очень простой настройки:
- Новый UITableView с контроллером MyTableView
- 1 прототип ячейки с классом MyTableViewCell
- С ячейкой связан 1 ярлыкto MyTableViewCell.label
У меня есть следующие ограничения для метки:
Это нужно, чтобы убедиться, что у меня естьминимальная высота ячейки 44.
Контроллер вида:
import UIKit
class MyTableViewController: UITableViewController {
let data: [String] = [
"One ",
"Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two Two ",
"Three "
]
override func viewDidLoad() {
super.viewDidLoad()
tableView.estimatedRowHeight = 44.0
tableView.rowHeight = UITableView.automaticDimension
}
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return data.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath) as! MyTableViewCell
cell.label.text = data[indexPath.row]
return cell
}
}
Ячейка:
import UIKit
class MyTableViewCell: UITableViewCell {
@IBOutlet weak var label: UILabel!
}