UITableView自动调整大小的行约束在iPhone 6Plus上神秘地打破 [英] UITableView auto resizing row constraint breaking mysteriously on iPhone 6Plus
问题描述
我有一个自定义UITableViewCell,其中包含缩略图和一堆文本.行高配置为使用
I have a custom UITableViewCell which has a thumbnail and bunch of text. The row height is configured to be calculated automatically using
tableView.estimatedRowHeight = 129;
tableView.rowHeight = UITableViewAutomaticDimension
行高应精确地计算为 138 个点. 在iPhone 5上,一切看起来都很不错.但是,在iPhone 6 Plus上,具有以下日志的随机行的自动行高会间歇性地失败.
The row height should be calculated as exactly 138 points. Everything looks great on the iPhone 5. However, on iPhone 6 Plus, the auto row height fails INTERMITTENTLY for random rows with the following log.
(
"<NSLayoutConstraint:0x17009ddd0 V:|-(20)-[scoop.ThumbnailImage:0x124d2a5a0] (Names: '|':UITableViewCellContentView:0x124e23200 )>",
"<NSLayoutConstraint:0x17009de70 UITableViewCellContentView:0x124e23200.bottomMargin == scoop.ThumbnailImage:0x124d2a5a0.bottom + 20>",
"<NSLayoutConstraint:0x17009e780 V:[scoop.ThumbnailImage:0x124d2a5a0(90)]>",
"<NSLayoutConstraint:0x17009ef00 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x124e23200(138.333)]>"
)
日志的最后一行似乎说,由于某种原因,行高被计算为 138.333 而不是138 .我已经打了一段时间,但我不知道为什么会这样.有人可以帮忙吗?
The last line of the log seems to say that for some reason the row height was calculated as 138.333 instead of 138. I have been banging my head for a while now but I am unable to figure out why this is happening. Can some one please help?
更新:这是我的表格视图单元格的样子.
Update: This is how my table view cell looks like.
更新我无法从主存储库中获取代码,因为它是较大项目的一部分.但是我设法通过一个非常简单的理智的项目重现了这个问题.请在在github上找到它.
UPDATE I couldn't get the code out of the main repo since its a part of a bigger project. But I have managed to reproduce the issue with a very simple sane project. Please find it here on github.
推荐答案
此警告告诉您约束中存在冲突. 将高度限制的优先级降低到999,它将消失.在您的Github项目中对其进行了测试,并且效果很好.
This warning is telling you there's a conflict in your constraints. Reduce the priority of the height constraint to 999 and it will go away. Tested it in your Github project and worked perfectly.
这篇关于UITableView自动调整大小的行约束在iPhone 6Plus上神秘地打破的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!