Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode reload just one cell in UiCollectionView

I want to reload just one cell in a UICollectionView.

I know in UITableView it is something like this :

[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPathOfYourCell, nil] withRowAnimation:UITableViewRowAnimationNone];

but what about UICollectionView?

like image 741
user3001228 Avatar asked Mar 01 '15 11:03

user3001228


People also ask

What is the difference between UICollectionView and UITableView?

For the listing details of each item, people use UITableView because it shows more info on each item. The UICollectionView class manages an ordered collection of data items and presents them using customizable layouts.

What is UICollectionView flow layout?

A layout object that organizes items into a grid with optional header and footer views for each section.

How do I add a section title in UICollectionView?

There are no section headers in the UICollectionView. So for your first task, you'll add a new section header using the search text as the section title. To display this section header, you'll use UICollectionReusableView .

What is the use of datasource and delegate in UICollectionView in IOS?

This method asks the data source object to provide a supplementary view to display in the collection view. It asks the datasource object whether the specified item can be moved to another location in the collectionview. This method moves the specified item to the specified indexpath.


2 Answers

Use the method called reloadItemsAtIndexPaths:

[self.collectionView reloadItemsAtIndexPaths:@[indexPathOfYourCell]];
like image 192
Michał Ciuba Avatar answered Nov 01 '22 22:11

Michał Ciuba


For swift 4 use this code:-

self.collectionView.reloadItems(at: [indexPath!])
like image 43
Bijender Singh Shekhawat Avatar answered Nov 01 '22 22:11

Bijender Singh Shekhawat