简体   繁体   中英

Cannot override mutable property 'collectionView' of type 'UICollectionView?' with covariant type 'GeminiCollectionView?'

I have had a custom collection view and everything worked fine. I wanted to include 'Gemini' to make beautiful animations when sliding my cells horizontally. I believe that the problem is not Gemini, I think the same would have happen with changing VC class to any other one, but I dont know how to solve this because I never faced with this before, is there a shortcut from this?

I have installed and imported the pod into code.
I had a UICollectionViewController but to work with gemini I needed to connect my collectionView from Storyboard to ViewController. Before that, I have put a class in Storyboard for my CollectionView to be GeminiCollectionView like in the image below:
故事板 coll.view 类

After that, I changed a class for my CollectionView in ViewController, too, like in the image below and got those three errors:
在此处输入图像描述

In the later code, it doesnt show any errors:
viewDidLoad

collectionView.gemini
            .rollRotationAnimation()
            .degree(45)
            .rollEffect(.rollUp)


cellForItemAt

self.collectionView.animateCell(cell)


scrollViewDidScroll

self.collectionView.animateVisibleCells()


willDisplay cell

if let cell = cell as? RatingCell {
//RatingCell inhertis the GeminiCell class
            self.collectionView.animateCell(cell)
        }

So, all the code is fine except the declaration as I mentioned at the beginning and here:

@IBOutlet var collectionView: GeminiCollectionView!



Waiting for random guys to unvote this:P

Solved

@IBOutlet var collectionView: GeminiCollectionView!

That line was a problem. Seems like you mustn't default Swift's name to override mutable property, which is collectionView for Collection Views and tableView for Table Views.
I changed that line to

@IBOutlet var collView: GeminiCollectionView!

...and the errors disappeared.

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