You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i'm trying to create a custom cell providing a xib and a setup method.
My cell has all the autolayout constraints needed to adapt to the quantity of text in the labels, but the library uses the height closure to compute cell height (forcing me to recalculate what the constraints are alredy doing, and to keep the closure updated every time i tweak the xib)
that is wrong, it should use the constraints and dynamically size the cells.
umm.. i didn't know about it, anyway it's not working, i'm still getting an autogenerated constraint that reduce my cell height: <NSLayoutConstraint:0x7af931e0 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7af4cee0(65)]>
Ok, here is the project. My original cell is "ResizingLabelCell", but i made another simpler cell with just a label. The label is configured with "0 lines" and "Word wrap", so it should expand to the size of the text. Also, if you look with "View debugging -> capture view hierarchy" you'll see that the constraint which set the height of the label is consistent with the content, but then there is the "encapsulated layout height" which ruins everything...
and comment the willDisplayCell at row 629 (so it isn't called twice), all the layout is perfect!
Why? I have no idea. Just another of the thousand quirks of UITableView i guess.. Could you please give me some feedback about if this patch is acceptable or maybe it breaks something else?
I don't remember why i put these code into willDisplayCell, apparently it works perfectly after deleting these method and adding the .updateCell() invocation from cellForRowAtIndexPath so go ahead and make a pull request.
Apparently we don't even need the following linetableView?.estimatedRowHeight = UITableViewAutomaticDimension customization.
Activity
mtnbarreto commentedon Apr 27, 2016
I think your cell.height should return
UITableViewAutomaticDimension
.from row setup method...
Could you confirm that this works for you?
I'm not sure if you also need to update tabeView's
estimatedRowHeight
:hariseldon78 commentedon Apr 27, 2016
umm.. i didn't know about it, anyway it's not working, i'm still getting an autogenerated constraint that reduce my cell height:
<NSLayoutConstraint:0x7af931e0 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7af4cee0(65)]>
mtnbarreto commentedon Apr 27, 2016
@hariseldon78 Could you share the code by uploading a project to reproduce the issue?
hariseldon78 commentedon Apr 27, 2016
sure, i'll do that after dinner
hariseldon78 commentedon Apr 27, 2016
testEurekaCustomCell copy.zip
Ok, here is the project. My original cell is "ResizingLabelCell", but i made another simpler cell with just a label. The label is configured with "0 lines" and "Word wrap", so it should expand to the size of the text. Also, if you look with "View debugging -> capture view hierarchy" you'll see that the constraint which set the height of the label is consistent with the content, but then there is the "encapsulated layout height" which ruins everything...
hariseldon78 commentedon Apr 27, 2016
Hey, I think i've got something: if i modify the Core.swift at row 707 like this:
and comment the
willDisplayCell
at row 629 (so it isn't called twice), all the layout is perfect!Why? I have no idea. Just another of the thousand quirks of UITableView i guess.. Could you please give me some feedback about if this patch is acceptable or maybe it breaks something else?
mtnbarreto commentedon Apr 28, 2016
I don't remember why i put these code into willDisplayCell, apparently it works perfectly after deleting these method and adding the
.updateCell()
invocation from cellForRowAtIndexPath so go ahead and make a pull request.Apparently we don't even need the following line
tableView?.estimatedRowHeight = UITableViewAutomaticDimension
customization.fix autolayout in cells