【问题标题】:func collectionViewContentSize in Swift3Swift3 中的 func collectionViewContentSize
【发布时间】:2016-08-02 19:55:38
【问题描述】:

我已经在 Xcode 8 中将我的项目更新为 Swift3,它出现了这个错误,但我不知道我可以在那里做什么。我已经在谷歌搜索但没有找到任何东西。 有人知道我能做什么吗?

这里是错误:

使用 Objective-C 选择器“collectionViewContentSize”的方法“collectionViewContentSize()”与具有相同 Objective-C 选择器的超类“UICollectionViewLayout”中的“collectionViewContentSize”的 getter 冲突

  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!
    }

【问题讨论】:

    标签: uicollectionview swift3 xcode8 contentsize cgsize


    【解决方案1】:

    我有类似的东西,但我覆盖了 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)
    }
    

    我今天下载了 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)
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-22
      • 1970-01-01
      • 2017-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-07
      相关资源
      最近更新 更多