@Rincewind Here's code for reproducing the issue by setting the maximum size on the cell:
class ViewController: UIViewController {
func addButtons(to stack: UIStackView) {
let titles = ["Button 1", "Button 2", "Button 3"]
for title in titles {
let button = button(title: title)
let heightConstraint = NSLayoutConstraint(
item: button,
attribute: NSLayoutConstraint.Attribute.height,
relatedBy: NSLayoutConstraint.Relation.greaterThanOrEqual,
toItem: nil,
attribute: NSLayoutConstraint.Attribute.notAnAttribute,
multiplier: 1,
constant: 48
)
button.addConstraint(heightConstraint)
stack.addArrangedSubview(button)
}
}
func button(title: String) -> UIButton {
var configuration = UIButton.Configuration.plain()
configuration.titleAlignment = .leading
configuration.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in
var outgoing = incoming
outgoing.foregroundColor = UIColor.blue
outgoing.font = UIFont.preferredFont(forTextStyle: .body)
return outgoing
}
let button = UIButton(configuration: configuration)
button.setTitle(title, for: .normal)
return button
}
}
extension ViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? TextCell else { return UITableViewCell() }
cell.maximumContentSizeCategory = .extraLarge
addButtons(to: cell.stackView)
return cell
}
}
class TextCell: UITableViewCell {
@IBOutlet var stackView: UIStackView!
}
Post
Replies
Boosts
Views
Activity
@Rincewind Unfortunately I'm unable to post the code publicly, but in trying to reduce the issue I've only been able to do so by setting the maximumContentSizeCategory of the cell itself (in cellForRowAtIndexPath) vs. setting it on the view controller's root view in viewDidLoad. I'm still trying to figure out why that is.
Update on this: I found that a 3rd-party library somehow was causing the issue. Removing the library caused coverage to start working again.
Thanks! I tried updating to Xcode 14.3 but that did not fix the issue for me; will continue to investigate.