I am following a tutorial where using the UIPickerController
to operate the camera. However when implementing UICollectionViewDatsaSource
, I get an error saying that ViewController
does not conform to the UICollectionViewDataSource
protocol.
class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, UIImagePickerControllerDelegate, UINavigationControllerDelegate
Any idea on how to fix this problem?
You must implement this two method in your ViewController
class:
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {}
P.S. - Your function prototype should exactly match with above functions.(remove any '!'
if present)
You have to implement these two method in your ViewController class for Collection View :
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
<#code#>
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
<#code#>
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With