动态调整UITableViewCell的大小以适应内容

问题描述:

我有4个静态UITableViewCells,每个都有UITextView和UIView。 textView和视图都动态调整大小,并且每一方都有4个约束。



我想要实现的是让UITableViewCell动态调整大小。我无法做到这一点。



我无法返回textView +视图高度的方法heightForRowAtIndexPath,因为视图位于iboutletCollection中。



希望我足够清楚。如果您有任何疑问,请随时询问

I have 4 static UITableViewCells with a UITextView and a UIView in each of them. Both the textView and the view get resized dynamically and they both have 4 constraints on each side.

What I'm trying to achieve is making the UITableViewCell resize dynamically. I'm having trouble doing that.

I cannot return the height of the textView + the view in the method heightForRowAtIndexPath because the view is in an iboutletCollection.

Hope I was clear enough. If you have any questions, feel free to ask

您可以继承UITableViewCell并在方法calc或设置高度。但是,必须在界面构建器的属性检查器中设置单元的标识。
You can subclass UITableViewCell and in the method calc or set the height. But you must set the Identity of the cell in the Attribute inspector in the interface builder.