Reputation: 524
I have another question open where I'm trying to figure out how to reload the collectionView without auto-scrolling. I was also realizing there are a lot of other situations where I will need to change things in the collection view. Also I have some items that I will want to change the .alpha on and change the text of. Is there a way to do all of this in Swift? For example (to be specific) if I have a collection view with a view in each cell and that view has a textField in it, can I change the alpha and text, (change alpha with animation even) without reloading entire table?
Upvotes: 0
Views: 594
Reputation: 5712
Most appropriate where you can update your custom view of a particular UIcollectionViewcell is reloadItemsAtIndexPaths
.
You would be handling a particular item than whole collectionview with reloadData
.
You can handle it via notifications or some call backs in your code where you can make decision when to update which cell.
Hope it will help you.
Upvotes: 0
Reputation: 318814
Look at the documentation for UICollectionView
. There are several "reload" methods:
reloadData()
reloadSections(_:)
reloadItems(at:)
If you just want to reload a single item, update your data source's data and then call reloadItems(at:)
passing in the index path for the item.
Another option, if a cell is currently visible, is to use the cellForItem(at:)
method to get a reference to an existing cell. Then you can directly access UI components of the cell as needed. You should also update your data model as needed so if the user scrolls and comes back, the cell will be rendered properly.
Upvotes: 1