Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

func collectionViewContentSize in Swift3

I have update my Project to Swift3 in Xcode 8 and it comes this error but I have no idea what I can make there. I have already search in google but nothing founded. Have anyone an Idea what I can make ?

Here the Error:

Method 'collectionViewContentSize()' with Objective-C selector 'collectionViewContentSize' conflicts with getter for 'collectionViewContentSize' from superclass 'UICollectionViewLayout' with the same Objective-C selector

  public func collectionViewContentSize() -> CGSize {
        let numberOfSections = collectionView?.numberOfSections
        if numberOfSections == 0 {
            return CGSize.zero
        }

        var contentSize = collectionView?.bounds.size
        contentSize?.height = CGFloat(columnHeights[0])

        return contentSize!
    }
like image 875
Marshall Avatar asked Aug 02 '16 19:08

Marshall


1 Answers

I had something similar but I was overriding collectionViewContentSize()

override func collectionViewContentSize() -> CGSize {
    let collection = collectionView!
    let width = collection.bounds.size.width
    let height = max(posYColumn1, posYColumn2)

    return CGSize(width: width, height: height)
}

I Downloaded XCode 8 beta 4 today and have had to change it to:

override var collectionViewContentSize: CGSize {
    let collection = collectionView!
    let width = collection.bounds.size.width
    let height = max(posYColumn1, posYColumn2)

    return CGSize(width: width, height: height)
}
like image 171
Magnas Avatar answered Nov 17 '22 21:11

Magnas