Srikanth Adavalli
Srikanth Adavalli

Reputation: 685

How can i refresh buttons inside a cell in CollectionView?

Given that: For example in a collectionView there are 8 cells & each cell has a button & an image.Buttons here will display Yes/No Option to the user. Out of 8 cells only 1 cell will show "Yes" and remaining cells should show "No".

What i am looking is? When i tap on a different button then current button show display "Yes" and previous button display "No".

I don't want to reload entire collectionView or cells inside a section in collectionView.

Upvotes: 0

Views: 829

Answers (1)

Shailesh Chandavar
Shailesh Chandavar

Reputation: 1614

You can make use of reloadItemsAtIndexPaths method of collection View to reload multiple cells(In your case 2 cell i.e the minimum number of cells to be reloaded) instead of reloading whole collectionView.Pass the indexpath of the cell that you want to reload ex:

  //Logic to change button title Yes to No comes here.
  collectionView.reloadItemsAtIndexPaths([indexPath1, indexPath2])

indexPath1, indexPath2 are the index paths to be reloaded.

Upvotes: 1

Related Questions