垂直滚动集合视图内表视图单元格

时间:2016-09-03 13:02:25

标签: ios swift

我在该视图上有一个tableView和一个段控件设置。现在,当段的值更改时,我想删除现有的tableView单元格,并在其中一个tableView单元格中显示完整的collectionView。

我已经通过了https://github.com/ashfurrow/Collection-View-in-a-Table-View-Cell,虽然发现它非常有用,却找不到合适的解决方案。

我想要的collectionView也是垂直可滚动的,没有固定的高度

有人可以帮忙吗?

2 个答案:

答案 0 :(得分:0)

我在tableview单元格中的另一个tableview中回答了这个问题,这也适用于集合视图,我解释了它in this thread

问我是否遇到任何问题

答案 1 :(得分:-1)

extension TableViewCell {

func setCollectionViewDataSourceDelegate<D: protocol<UICollectionViewDataSource, UICollectionViewDelegate>>(dataSourceDelegate: D, forRow row: Int) {

    collectionView.delegate = dataSourceDelegate
    collectionView.dataSource = dataSourceDelegate
    collectionView.tag = row
    collectionView?.alwaysBounceVertical = true
    collectionView.setContentOffset(collectionView.contentOffset, animated:false) // Stops collection view if it was scrolling.
    collectionView.reloadData()
}

var collectionViewOffset: CGFloat {
    set {
        collectionView.contentOffset.x = newValue
    }

    get {
        return collectionView.contentOffset.x
    }


   }
}
相关问题