FUITableViewCollectionSection

open class FUITableViewCollectionSection

The FUITableViewCollectionSection control is designed to be used, when a section in a UITableView should be dedicated to displaying a UICollectionView, and, the height of that section should adjust to fit its contents.

FUITableViewCollectionSection

The collection section produces a single FUICollectionViewTableViewCell, which refreshes its height, after its subview FUICollectionView calculates the sizes of its subview UICollectionViewCell items.

A developer uses the FUITableViewCollectionSection, by assigning a data source (/and delegate) to its collectionView: FUICollectionView property; then, he or she should supply its collectionViewTableViewCell property to a UITableViewDataSource.tableView(_:cellForRowAt:) implementation.

Important

A developer should retain a strong reference to a FUITableViewCollectionSection.

## Usage

    let workorders: [WorkOrder] = [WorkOrder]()

    override public func viewDidLoad() {

        let workOrdersLayout = FUICollectionViewLayout.horizontalFlow
        workOrdersLayout.itemSize = CGSize(width: 200, height: 200)
        self.workOrdersSection = FUITableViewCollectionSection(tableView: self.tableView, collectionViewLayout: workOrdersLayout)
        self.workOrdersSection.collectionView.dataSource = self
        self.workOrdersSection.collectionView.register(FUISimpleCollectionViewCell.self, forCellWithReuseIdentifier: FUISimpleCollectionViewCell.reuseIdentifier)
        self.workOrdersSection.collectionView.delegate = self
        self.workOrdersSection.collectionView.isScrollEnabled = false

        self.tableView.estimatedRowHeight = 98
        self.tableView.rowHeight = UITableViewAutomaticDimension

    }

    // MARK:  UITableViewDataSource
    override public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }

    public override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        return self.workOrdersSection.collectionViewTableViewCell
    }

    // MARK:  UICollectionViewDataSource
    public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

        switch collectionView {
        case workOrdersSection.collectionView:
            let cell = collectionView.dequeueReusableCell(withReuseIdentifier: FUISimpleCollectionViewCell.reuseIdentifier,
                                                                          for: indexPath) as! FUISimpleCollectionViewCell
            cell.contentImageView.image = UIImage(named: "WorkOrderImage")
            cell.titleLabel.text = "Work Order: \(indexPath.item)"
            return cell
        default:
            // ...
        }
    }