NSLayoutConstraint "UIView-Encapsulated-Layout-Height" is added incorrectly for a "regular" situation

My application has a UITableView whose rows have a minimum height limit based on the size of the class. In particular, strings have a minimum height of 45 in "any-any" and a minimum height of 65 in "regular regular" (for example, iPads). I ensured that a height limit of 45 was set only for any-any, and a height limit of 65 was set only for regular regulars.

I get "Unable to satisfy constraints at the same time." run-time warning on iPad mini running iOS 8.3 due to the UIView-Encapsulated-Layout-Height restriction that iOS adds. I read this SO question , but I don't think this issue is addressed there.

Here are the conflicts that are in conflict:

"<NSLayoutConstraint:0x19116b00 V:|-(0)-[UILabel:0x19115fd0'text'] (Names: '|':UITableViewCellContentView:0x19115f00 )>", "<NSLayoutConstraint:0x19116b30 V:[UILabel:0x19115fd0'text']-(0)-| (Names: '|':UITableViewCellContentView:0x19115f00 )>", "<NSLayoutConstraint:0x191172c0 V:[UILabel:0x19115fd0'text'(>=65)]>", "<NSLayoutConstraint:0x19087f30 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x19115f00(45)]>" 

It looks like 45 is used to calculate the UIView-Encapsulated-Layout-Height limit, even if 45 is not set for regular regulars. In fact, this violates the height limit of 65 and uses 45, making the lines short. When I scroll the lines from the screen and back, their height is calculated correctly.

Note that I am using the following in ViewDidLoad:

 self.tableView.rowHeight = UITableViewAutomaticDimension self.tableView.estimatedRowHeight = 60.0; 

I tried to set the priority for height 65 from 1000 to 750. This no longer gives a warning, but the behavior is the same since it uses 45 for height.

I even tried using "[self.tableView reloadData]" in ViewDidAppear, but it will show the wrong height before resizing correctly.

Any ideas?

+5
source share

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


All Articles