How can I customize a UITableViewCell with a UIStackView inside it?

I can not achieve self-determination UITableViewCellwith the UIStackViewinside.

For UITableViewCellI do something like this:

ui

On code, I do this:

override func viewDidLoad() {
    super.viewDidLoad()
    self.tableView.estimatedRowHeight = 80
}

But when I run the application, it UITableViewCelldoes not change sizes:

result

What am I missing to UITableViewCellindependently determine the dimensions using UIStackViewinside?

+5
source share
5 answers

Do you have multi-line tags? If so, make sure that you have the line property in IB equal to 0, not 1.

Top and bottom of the stack.

If not, check the following:

override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    return UITableViewAutomaticDimension
}

override func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    return UITableViewAutomaticDimension
}
+2
source

UITableViewCell , - , , . .

, .

+1

. , stackView , .., , .

.

0

. , .

height 64, , 1000. , , , Fill. Stack View, Stack View 64. 64 . , Center , 64.

0

Here is a simple example of using UIStackViewfor UIStackViewand collapsing size variables UITableViewCellwith automatic layout.

0
source

Source: https://habr.com/ru/post/1652527/


All Articles