Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout attributes were received from the layout but are not valid for the data source counts. Attributes will be ignored. #47

Open
WestFR opened this issue Nov 10, 2020 · 4 comments

Comments

@WestFR
Copy link

WestFR commented Nov 10, 2020

Hello,

First of all, apologize for my level of English language.
I have setup a view collection with a search bar and filters. The layout being made with your package.

When i perform a reload on this with this method : self.collectionView.collectionViewLayout.invalidateLayout().

I obtain this error on the debugger :

[CollectionView] Layout attributes <CollectionViewSlantedLayout.CollectionViewSlantedLayoutAttributes: 0x7ff1035113c0> index path: (<NSIndexPath: 0xbcd26c36f94746f0> {length = 2, path = 0 - 3}); frame = (0 603; 414 275); zIndex = 3;  were received from the layout <CollectionViewSlantedLayout.CollectionViewSlantedLayout: 0x7ff1035148a0> but are not valid for the data source counts. Attributes will be ignored.

After research i solved it by adding this method to your class CollectionViewSlantedLayout.swift

The method to add is :

override open func invalidateLayout() {
    super.invalidateLayout()
    self.cachedAttributes.removeAll()
}

I can put this code and make a pull request if you want and if you are ok.

@stale
Copy link

stale bot commented Jun 26, 2021

Thanks for your contribution!

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version
  2. Comment that the issue is still reproducible and include:
    • What version of CollectionViewSlantedLayout you reproduced the issue on
    • What steps you followed to reproduce the issue

Issues that are labeled as crash will not be automatically marked as stale.

@stale stale bot added the stale label Jun 26, 2021
@WestFR
Copy link
Author

WestFR commented Nov 16, 2021

@yacir If you want up this issue :)

@stale stale bot removed the stale label Nov 16, 2021
@DreaMorrin
Copy link

DreaMorrin commented Nov 27, 2022

Hi @yacir , thanks for sharing the great feature and its implementation! I also experienced the similar issue that the layout is all messed up when try to reload. I found the issue is due to non-clean-invalidation before recalculation. Amend to what @WestFR suggested, the following would be the solution. Thanks!

override open func invalidateLayout() {
        super.invalidateLayout()
        self.cachedAttributes.removeAll()
        self.cachedContentSize = 0
        self.currentSize = CGSize.zero
}

@yacir
Copy link
Owner

yacir commented Nov 28, 2022

@WestFR @DreaMorrin Hello guys ! sorry i was busy with other projects. I'll fix it soom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants