简体   繁体   中英

Cannot Call Value of Non Function Type Swift 3

I am trying to convert my project to swift 3 but get the following error on my code:

Code:

super.collectionView(collectionView, willDisplayCell: cell, forItemAtIndexPath: indexPath)

Error:

Cannot Call Value of Non-function type 'uicollectionview'

Does anyone know the swift 3 edit?

If you are subclassing a UICollectionViewController you should be able to use this:

override func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
    super.collectionView(collectionView, willDisplay: cell, forItemAt: indexPath)
}

If you are not subclassing a UICollectionViewController you will likely have to use this:

@objc(collectionView:willDisplayCell:forItemAtIndexPath:) func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {

}

I have both types of collection views in my apps that I've been updating, and that is what works for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM