Comments (6)
Hi @Wolly1985,
UICollectionView.moveItem
doesn't call cellForItemAtIndexPath
.
If you want to update the cell appearance, you should return a false
value in your model's isContentEqual(to:)
.
This way DifferenceKit will call reloadItem
and update cell appearances.
from differencekit.
Hi @ra1028 this reload all cells and not only this that moves. also the call reloadItem is before the item is move to the another section
greetz
from differencekit.
i found a Soulution with a edit CollectionView Extension. thx for help
`public extension UICollectionView {
func reload<C>(
using stagedChangeset: StagedChangeset<C>,
reloadChangeCells: Bool,
interrupt: ((Changeset<C>) -> Bool)? = nil,
setData: (C) -> Void
) {
if case .none = window, let data = stagedChangeset.last?.data {
setData(data)
return reloadData()
}
let contentOffset = self.contentOffset
var indexPaths: [IndexPath] = []
for changeset in stagedChangeset {
if let interrupt = interrupt, interrupt(changeset), let data = stagedChangeset.last?.data {
setData(data)
return reloadData()
}
performBatchUpdates({
setData(changeset.data)
if !changeset.sectionDeleted.isEmpty {
deleteSections(IndexSet(changeset.sectionDeleted))
}
if !changeset.sectionInserted.isEmpty {
insertSections(IndexSet(changeset.sectionInserted))
}
if !changeset.sectionUpdated.isEmpty {
reloadSections(IndexSet(changeset.sectionUpdated))
}
for (source, target) in changeset.sectionMoved {
moveSection(source, toSection: target)
}
if !changeset.elementDeleted.isEmpty {
deleteItems(at: changeset.elementDeleted.map { IndexPath(item: $0.element, section: $0.section) })
}
if !changeset.elementInserted.isEmpty {
insertItems(at: changeset.elementInserted.map { IndexPath(item: $0.element, section: $0.section) })
}
if !changeset.elementUpdated.isEmpty {
reloadItems(at: changeset.elementUpdated.map { IndexPath(item: $0.element, section: $0.section) })
}
for (source, target) in changeset.elementMoved {
moveItem(at: IndexPath(item: source.element, section: source.section), to: IndexPath(item: target.element, section: target.section))
indexPaths.append(IndexPath(item: target.element, section: target.section))
}
}) { (complete) in
if reloadChangeCells {
self.reloadItems(at: indexPaths)
}
}
}
if contentSize.height > bounds.size.height {
setContentOffset(contentOffset, animated: false)
}
}
}`
from differencekit.
my solution crashs after move many items has completion conflict with the datasource. but in performBatchUpdates its to early because when call moveItem, reloadItems(at: indexPaths) crashs because wrong index.
from differencekit.
@Wolly1985
Sorry for my late reply.
I think you should contain all the rendering information in your model instance.
But you can workaround as below is also possible.
collectionView.reload(using: changeset) { data in
self.data = data
}
collectionView.indexPathsForVisibleItems.forEach { indexPath in
guard let cell = collectionView.cellForItem(at: indexPath) else { return }
cell.alpha = indexPath.section == 0 ? 1 : 0.5
}
from differencekit.
I close this issue.
If you still want to ask, please reopen it.
from differencekit.
Related Issues (20)
- CollectionDifference API implementation HOT 1
- Compute changeset in the background
- To do the insert and delete operations at once
- Delete .swift-version
- Crash when I reload collectionView HOT 1
- Help needed with crash - NSInternalInconsistencyException HOT 1
- Buggy default reload method HOT 1
- How can I reload a table that is behind on the navigation stack? HOT 1
- UICollectionView reload animation
- Duplicate items with some edge cases in AppKitExtension HOT 13
- Why DifferenceKit is so much faster than Apple's Foundation diffing? HOT 2
- Animation option for row reloading is not a valid option in AppKitExtension
- Does it work seamlessly when using an UICollectionView with SwiftUI cells? HOT 2
- tvOS UICollectionView.reload crash
- The algorithm cannot get the best diff results? HOT 1
- `Differentiable` requres `Equatable` AND `Hashable`, but docs say otherwise
- Using only the diffing algorithm
- Invalid batch updates detected
- How to apply ChageSet to an array?
- Use UITableView reconfigureRows and UICollectionView reconfigureItems for ChangeSet.elementUpdated
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from differencekit.