How to implement UICollectionView inside UICollectionViewCell right way?
hhoangna opened this issue · comments
Hi @ekazaev. So sorry about reopening this issue.
I had try to set new size of cell in function func preferredLayoutAttributesFitting(_ layoutAttributes: ChatLayoutAttributes) -> ChatLayoutAttributes?
But it still not working smooth. It's wrong in the first load. This is my code for UICollectionView in UICollectionViewCell
Please review and show to me my mistake.
Can you give me a tutorial project?
Thanks so much
SGIComponentActionView.swift.zip
Originally posted by @hhoangna in #44 (comment)
@hhoangna No problem, but just reopen the issue next time.
As I said, I can only direct you. By the look of layoutAttributes.frame.size.height = collectionView.collectionViewLayout.collectionViewContentSize.height + borderHeight + itemHeight
this assumption is correct. Did you check that at the moment ChatLayout
asks for the preferredLayoutAttributesFitting
it contains the correct size? I doubt it. I dont see any code that forces the internal collection view to calculate its size before the cell is being measured. I cant run your code, youll have to come back with the Example project. So run the code yourself and put the breakpoint into preferredLayoutAttributesFitting
and make sure that you set the correct height at the very first time.
PS: One more thing to keep in mind that if you'll require to change that height - you must call reloadItems
or reconfigureItems
on your collection view.
Hi @ekazaev
Finally, after a few days working so hard :(
I have resolved my problem. Thanks for your support 👯
And one more question please?
Can i use SkeletonView with ChatLayout? I just try and give a crash
Hi @hhoangna. Congratulations.
I am not sure about skeleton view. ChatLayout doesn't do anything that goes against UIKit rules. But i know it has lots of issues open https://github.com/Juanpe/SkeletonView/issues. It also uses some hacks so I'd recommend you against it.