func collectionViewContentSize in Swift3
Asked Answered
S

1

8

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!
    }
Sculptor answered 2/8, 2016 at 19:55 Comment(0)
C
41

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)
}
Catchy answered 3/8, 2016 at 7:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.