I'm using UICollectionView
in my swift class, it's placed on my UIViewController
. I connected the collectionView to the outlet in my code, I set up delegate
and datasource
and I see the outcome in my app. Everything works besides the fact that when I click each cell - nothing happens.
My code is as follows:
class UsersList: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {
@IBOutlet weak var tview: UICollectionView!
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
tview.backgroundColor = UIColor.whiteColor() //this works
tview.delegate = self
tview.dataSource = self
}
func collectionView(tview: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
print("You selected cell #\(indexPath.item)!")
//this does not appear in the console :(
}
Is there anything else I could do to see the print msg in the console?
In swift, the parameter name and function name identify a function together. UICollectionViewDelegate have function
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath)
but not
func collectionView(tview: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath)