如何判断的UITableView的自施胶细胞的高度大约为改变? [英] How to tell UITableView that a self-sizing cell's height is about to change?

查看:159
本文介绍了如何判断的UITableView的自施胶细胞的高度大约为改变?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITableView,其内容是有些动态的。似乎每次我调整他们,我打这个错误:

I've got a UITableView whose contents are somewhat dynamic. It seems like every time I resize them, I hit this error:

Unable to simultaneously satisfy constraints.

    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 

(

    "<NSLayoutConstraint:0x15dbabf0 WKWebView:0x15da1650.top == UITableViewCellContentView:0x15eaedb0.topMargin>",

    "<NSLayoutConstraint:0x15dbac20 UITableViewCellContentView:0x15eaedb0.bottomMargin == WKWebView:0x15da1650.bottom>",

    "<NSLayoutConstraint:0x15db1360 V:[WKWebView:0x15da1650(158)]>",

    "<NSLayoutConstraint:0x15ed0c00 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x15eaedb0(43.5)]>"

)

这是最后一个 - 一个标记 UIView的封装,布局,高度 - 那就是摔东西。我想摆脱它,或将其设置为优先破,或者说 - 但我不能似乎能够告诉的UITableView打破它。我已经试过各种意见 setNeedsUpdateConstraints setNeedsLayout 所有可能的组合。我试着从本小区的内容查看所有制约 updateConstraints 。我试着打电话是 beginUpdates endUpdates - 在这种情况下, updateConstraints 是从来没有所谓的放大器;约束没有被重新评估。

It's that last one - the one labeled UIView-Encapsulated-Layout-Height - that is breaking things. I want to get rid of it, or set it to a breaking priority, or something - but I can't seem to be able to tell UITableView to break it. I've tried every possible combination of setNeedsUpdateConstraints and setNeedsLayout on various views. I've tried removing all the constraints from the cell's contentView on updateConstraints. I've tried just calling beginUpdates and endUpdates - in that case, updateConstraints is never called & the constraints are not re-evaluated.

我不知所措,在这里。没有自我大小的细胞,只是打电话开始/用于触发细胞的尺寸的重新计算endUpdates。我现在该如何办呢?

I'm at a loss, here. Without self-sizing cells, just calling begin/endUpdates used to trigger a re-calculation of the cell's dimensions. How do I do it now?

推荐答案

您正在使用的内容视图内的WKWebView是打破制约的最可能的原因。同时,任何web视图的高度,只能在web视图加载完成后进行计算。对于例如在UIWebView中所述的UIWebView的高度可以被适当地仅在delgate方法didFinishLoadingWebView的方法取得。

The WKWebView which you are using inside the content view is the most possible cause of breaking constraints. Also the height of any webView can be calculated only when the WebView has finished loading. For e.g in UIWebView the height of the UIWebView can be fetched appropriately only in the delgate method "didFinishLoadingWebView" method.

此外,UIView的封装 - 布局 - 身高限制理应没有得到满意的大概计算细胞的内在高度有不同的价值。因此,人们可以降低相关的细胞约束的优先级,使UIView的封装,布局,高度有precedence。

Also, the 'UIView-Encapsulated-Layout-Height' constraints supposedly does not get satisfied as the cell's intrinsic height calculated probably has a different value. Hence one can lower the priority of the relevant cell constraint to allow UIView-Encapsulated-Layout-Height to have precedence.

这篇关于如何判断的UITableView的自施胶细胞的高度大约为改变?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆