【发布时间】:2017-11-15 16:51:40
【问题描述】:
在我的应用中,我有一个 tableView,其中包含多个带有 UICollectionView 的单元格,UICollectionView 的布局是自定义的,并在 cellForRowAtIndexPath 中设置。
在 collectionViewLayout 的 prepare 方法中,我将默认 contentOffset 设置为 collectionView。
但是这个 contentOffset 只适用于可见的表格单元格,当我滚动表格视图时,其他单元格没有这个default content offset。
如何解决这个问题?
override func prepare() {
guard cache.isEmpty, let collectionView = collectionView else {
return
}
// ...
// Prepare cell attributes and add to cache array
// ...
collectionView.contentOffset = CGPoint(x: 100, y:0)
}
【问题讨论】:
标签: ios uitableview uicollectionview uicollectionviewlayout