Tutorial by Examples

Swift func createCollectionView() { let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout() let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height), collectionViewLayout: layout) collectionView.dataSource = sel...
// MARK: - UICollectionViewDelegateFlowLayout extension ViewController: UICollectionViewDelegateFlowLayout { func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize { return ...
Initialize a UICollectionView with a CGRect frame: Swift: let collection = UICollectionView(frame: CGRect(x: 0, y: 0, width: 200, height: 21)) Objective C: UICollectionView *collection = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, 200, 21)]; You can also create a UICollectionVi...
Every collection view must have a Datasource object. The Datasource object is the content that your app will display within the UICollectionView. At a minimum, all Datasource objects must implement the collectionView:numberOfItemsInSection: and collectionView:cellForItemAtIndexPath: methods. Requir...
Create a new project It can be just a Single View Application. Add the code Create a new Cocoa Touch Class file (File > New > File... > iOS > Cocoa Touch Class). Name it MyCollectionViewCell. This class will hold the outlets for the views that you add to your cell in the storyboard. ...
You can animate complex changes to your collection view using the performBatchUpdates method. Inside the update block, you can specify several modifications to have them animate all at once. collecitonView.performBatchUpdates({ // Perform updates }, nil) Inside the update block, you can pe...
Sometimes, if an action should be bind to a collection view's cell selection, you have to implement the UICollectionViewDelegate protocol. Let's say the collection view is inside a UIViewController MyViewController. Objective-C In your MyViewController.h declares that it implements the UICollecti...
Here we are managing multiple collection there delegate methods with didselect events. extension ProductsVC: UICollectionViewDelegate, UICollectionViewDataSource{ // MARK: - UICollectionViewDataSource func collectionView(_ collectionView: UICollectionView, numberOfItemsI...

Page 1 of 1