Software auto-shutdown changes inside UITableViewCell are updated only after orientation change

I have a UITableView with automatic row height and a custom UITableViewCell . Inside a UITableViewCell I first add some UIButton with UIButton software limitations. They are located perfectly as I want. Then, after 3 seconds ( NSTimer ), I delete all those UIButton and again add another number of them. (For example, I initially have 4 UIButtons , after 3 seconds I delete those 4 UIButton and add 3 different ones.

First

Originally After 3 seconds :

3 seconds later

Put a turn:

enter image description here

Why is this happening? I do not see any Autolayout warnings. In addition, after changing the orientation, everything is correctly positioned. What requires a change in orientation? How can I force this manually? (Rebooting the table view just for that seems too much)

PS: I tried using setNeedsUpdateConstraints , layoutIfNeeded , layoutSubviews , but to no avail.

Here's the UITableViewCell code: http://pastebin.com/TcHUXgDU . (Added pastebin so as not to pollute this space). But basically there is a configure: method that I have inside my tableview subclass, which I call in cellForRowAtIndexPath its containing UITableView . This method adds these limitations. In addition, after the timer is activated, the same code is called (in a different function), except that the number of elements added is different from the original number of elements.

This is my UITableViewCell layout: (Only the top, bottom, leading, end restrictions were added to the UIView "Outerview")

uitableviewcell layout

+5
source share
1 answer

You need to reload the UITableView, this will redesign the cell height

0
source

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


All Articles