我无法使用以下代码从流布局中检索 contentSize
let contentSize: CGSize = self.collectionView?.collectionViewLayout.collectionViewContentSize()!
相反,我得到错误:
Could not find member 'collectionViewContentSize'
如果我打印值,它会正确返回:
println("content size \(self.collectionView?.collectionViewLayout.collectionViewContentSize())")
这是 swift 编译器的问题吗?
最佳答案
您必须将collectionViewLayout
转换为特定布局。如果您使用 UICollectionViewFlowLayout
,它将看起来像这样:
if let flow = collectionMain.collectionViewLayout as? UICollectionViewFlowLayout
{
let contentSize: CGSize = flow.collectionViewContentSize()
}
关于ios - swift 中的 CollectionViewFlowLayout 的 collectionViewContentSize(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32044809/