1

I have a tableView and a segment Control setup on that view. Now when the segment's value changes I want to remove the existing tableView cells and display full collectionView in one of tableView cells.

I have already gone through https://github.com/ashfurrow/Collection-View-in-a-Table-View-Cell and though found it very useful, haven't found the right solution.

Also the collectionView I want to had is vertical scrollable with not fixed height

Can anyone help?

Julien Quere
  • 2,407
  • 16
  • 21
user2848975
  • 117
  • 1
  • 12

2 Answers2

0

i had answered this question in another tableview inside tableview cell that will work for collection view too ,i explained it in this thread

ask me if you faced any problem

Hamed Nova
  • 1,061
  • 9
  • 15
-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
    }


   }
}
Carlo
  • 813
  • 1
  • 15
  • 34
  • I am not able to setup the collectionView inside the tableView yet – user2848975 Sep 03 '16 at 13:45
  • I have the collection view completely setup in a different View Controller, can I just show the view Controller in a tableView cell? – user2848975 Sep 03 '16 at 14:00
  • I think yes. Maybe putting in your storyboard your VC in your dynamic cell. – Carlo Sep 03 '16 at 14:08
  • Hey, could you elaborate on that? – user2848975 Sep 05 '16 at 04:26
  • I have thought but I didn't find any solution. Try to look some video of "Lets build that app" when he talks about firebase. It is very interesting and he helps you to build a vertical collection view – Carlo Sep 05 '16 at 05:42
  • There you can try to put that in your tablet view – Carlo Sep 05 '16 at 05:43
  • I already have a vertical collection view. But how do you suggest it be put in tableview cell? – user2848975 Sep 06 '16 at 05:35
  • Take your collection view code and put into your customized table view cell. Then in your table view call the collection view. With for example cell.collectionView – Carlo Sep 06 '16 at 05:56