Messagekit: apply(_ layoutAttributes: UICollectionViewLayoutAttributes) not called when i load data from network

Created on 26 Jul 2018  ·  12Comments  ·  Source: MessageKit/MessageKit

  • 0.13.5
  • iphone SE 11.4,but not limit , it happened on every iphone device sometimes
  • Swift 4.0
        messageList.insert(contentsOf: immessages, at: 0)
        messagesCollectionView.reloadDataAndKeepOffset() 

wechatimg1
when i scroll to the visible cell,it does not automatically call the function ### apply(_ layoutAttributes: UICollectionViewLayoutAttributes)
so disordered layout

-->

question

Most helpful comment

yeah ,please close the issue

All 12 comments

Hi @chunxige, can you please be more specific? Did you make some custom changes to the function? Have you tried MessageKit 1.0?

Sent with GitHawk

no ,i use MessageKit 0.13.5,i try to update to MessageKit 1.0

Are you using custom cells? What makes you think apply isn't being called? It seems to be laying out the avatar and labels

Sent with GitHawk

What kind of cell class type?

no ,i use TextMessageCell,and i print Log the in that function ,i find when i scroll from last section postion to the top postion,it dont trigger the function ,and it use the last section's attributelayout as the top attributelayout

2018-07-26 11 31 11

Are you saying it never prints anything? Because we cache layouts and so scrolling through cells after they have been layed out the first time might not trigger apply. @SD10 would know if this assumption is correct or not. But as I stated earlier, it is laying out the avatar and labels so the function is being called

Sent with GitHawk

2018-07-26 12 12 59

i'm setting disabeld the layout cache ,but it still happend ,and i find the solution :
https://stackoverflow.com/questions/23995544/ios-applylayoutattributes-does-not-get-called-for-some-of-the-cells

and i refer to the MessageKit 1.0 , modified the code in MessagesCollectionViewLayoutAttributes in the MessageKit 0.13.5, and it works perfectly!
2018-07-26 12 17 12

So just to clarify, the issue was you were using MessageKit 0.13.5?

Sent with GitHawk

yes ,i am using MessageKit 0.13.5 now

Yeah we stopped caching in MessageKit 1.0 because it leads to unexpected behavior for the consumers of the framework. The old way of calculating equality of attributes was not good to say the least -- as you've fixed @chunxige

If you think this is resolved now, let me know and we'll close this issue 👍

yeah ,please close the issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandon-haugen picture brandon-haugen  ·  3Comments

nitrag picture nitrag  ·  3Comments

ChandraPrakashJangid picture ChandraPrakashJangid  ·  3Comments

ahmedwasil picture ahmedwasil  ·  3Comments

Abacaxi-Nelson picture Abacaxi-Nelson  ·  4Comments