ekazaev / ChatLayout

ChatLayout is an alternative solution to MessageKit. It uses custom UICollectionViewLayout to provide you full control over the presentation as well as all the tools available in UICollectionView. It supports dynamic cells and supplementary view sizes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to implement UICollectionView inside UICollectionViewCell right way?

hhoangna opened this issue · comments

commented
          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.

commented

Thanks @ekazaev so much!
I will create an Example project then send to you.

commented

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.