Skip to content

Instantly share code, notes, and snippets.

@limabeans
Created November 17, 2016 07:03
Show Gist options
  • Save limabeans/d84536a135878efa6e30dd1cd2d453e8 to your computer and use it in GitHub Desktop.
Save limabeans/d84536a135878efa6e30dd1cd2d453e8 to your computer and use it in GitHub Desktop.
embedded CV
import UIKit
class ViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
@IBOutlet weak var embeddedCV: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
// make ourselves the delegate and data source of the CV.
embeddedCV.delegate = self
embeddedCV.dataSource = self
}
func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 10
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CustomCVCell", for: indexPath) as! CustomCVCell
return cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment