Strange behavior of UITextView in UITableViewCell

后端 未结 2 605
一整个雨季
一整个雨季 2021-01-23 06:31

I have a cell that contains a few stackviews, bottom stackView contains a textView and a custom separator.

I want to create an option, when user tap on cell, it

2条回答
  •  误落风尘
    2021-01-23 06:58

    I didn't find answer, why the strange behavior of textView and cell height is happening, but I have solution for my problem.

    So it looks like tableView.estimatedRowHeight = 160 and tableView.rowHeight = UITableViewAutomaticDimension don't respect textView's maximum number of lines for all cells. cellForRow works fine, it sets the limitation, but the rows height is sometimes expanded and sometimes contracted.

    So I unwrapped textView and the bottom separator from StackView, replaced TextView with Label and set autolayaut constraints. Now it works fine, without strange behavior.

提交回复
热议问题