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

CollectionView doesn't clear sometimes #85

Closed
Banck opened this issue Aug 5, 2018 · 3 comments · Fixed by #87
Closed

CollectionView doesn't clear sometimes #85

Banck opened this issue Aug 5, 2018 · 3 comments · Fixed by #87

Comments

@Banck
Copy link

Banck commented Aug 5, 2018

Hello!
I've tried to create dummyCells and showing it, for example, first 5 sec and then clear collectionView and show real cells. But when I set new data some cells didn't remove from collectionView even I set empty array to dataSource:

var dummyModels: [Model] = []
        for _ in 0..<20 {
            let model = Model(object: [:])
            dummyModels.append(model)
        }
        dataSource.data = dummyModels

and after sometime call:
dataSource.data = matches
And on the screen I can see 2 empty cells and bellow them real cells:
http://joxi.ru/D2P6pJspD1XQr3
http://joxi.ru/xAe8abupz6aY2y

If I call

dataSource.data.removeAll()

On the screen I can see 2 cells. I've debugged and dataSource.data.count == 0.

@lkzhao
Copy link
Collaborator

lkzhao commented Aug 6, 2018

This is weird, can you provide more code. What presenter are you using. what kind of data source are you using?

@Banck
Copy link
Author

Banck commented Aug 6, 2018

@lkzhao Seems, I resolved this issue.
I have datasource:

        dataSource = ArrayDataSource(data: presenter!.matches, identifierMapper: { (index, data) -> String in
            return "\(data.id ?? 0)"
        })

and when I want to create empty cell my data.id nil. So all cells had identifier == 0. And then when I call dataSource.data.removeAll() some cells still on the screen.

Now I have dataSource:

dataSource = ArrayDataSource(data: presenter!.matches, identifierMapper: { (index, data) -> String in
            return "\(data.id ?? index)"
        })

and all is fine.

@lkzhao
Copy link
Collaborator

lkzhao commented Aug 8, 2018

@Banck Thanks for reporting. It shouldn't leave the cells on screen even if there are identifier conflicts. I will push a patch to fix this issue in next week. Please leave this open for now.

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

Successfully merging a pull request may close this issue.

2 participants