Swift3中的func collectionViewContentSize

Mar*_*all 8 contentsize uicollectionview cgsize swift3 xcode8

我在Xcode 8中将我的项目更新为Swift3,它出现了这个错误,但我不知道我能在那里制作什么.我已经在谷歌搜索但没有创建.有谁有想法我能做什么?

这里错误:

使用Objective-C选择器'collectionViewContentSize'的方法'collectionViewContentSize()'与来自超类'UICollectionViewLayout'的'collectionViewContentSize'的getter冲突,具有相同的Objective-C选择器

  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!
    }
Run Code Online (Sandbox Code Playgroud)

Mag*_*nas 41

我有类似的东西,但我重写了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)
}
Run Code Online (Sandbox Code Playgroud)

我今天下载了XCode 8 beta 4并且不得不将其更改为:

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

    return CGSize(width: width, height: height)
}
Run Code Online (Sandbox Code Playgroud)