title: Add CollectionView as Table View Header
body: <p>I want to show banner like this:</p>
  
  <p><a href="https://i.stack.imgur.com/bgO2v.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/bgO2v.jpg" alt="enter image description here"></a></p>
  
  <p>My approach is adding a <code>CollectionView</code> as a <code>TableViewHeader</code></p>
  
  <p>My code:</p>
  
  <pre><code>extension HomeViewController: UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
      func configureHeaderView() {
  
          let layout = UICollectionViewFlowLayout()
          layout.scrollDirection = .horizontal
          layout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
  
          let headerView = UICollectionView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: headerHeight), collectionViewLayout: layout)
          headerView.backgroundColor = .blue
          headerView.isPagingEnabled = true
          headerView.isUserInteractionEnabled = true
  
          headerView.dataSource = self
          headerView.delegate = self
          headerView.register(BannerCollectionViewCell.self, forCellWithReuseIdentifier: BannerCollectionViewCell.reuseIdentifier)
          headerView.showsHorizontalScrollIndicator = false
  
          tableView.tableHeaderView = headerView
      }
  
      // MARK: UICollectionViewDataSource
      func numberOfSections(in collectionView: UICollectionView) -&gt; Int {
          return 1
      }
  
      func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
          return 3
      }
  
      func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
          let cell = collectionView.dequeueReusableCell(withReuseIdentifier: BannerCollectionViewCell.reuseIdentifier, for: indexPath) as! BannerCollectionViewCell
          return cell
      }
  
      // MARK: UICollectionViewDelegateFlowLayout
      func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -&gt; CGSize {
          return CGSize(width: UIScreen.main.bounds.width, height: headerHeight)
      }
  }
  </code></pre>
  
  <p>My <code>BannerCollectionViewCell</code> has a default image.</p>
  
  <pre><code>class BannerCollectionViewCell: UICollectionViewCell {
  
      @IBOutlet weak var bannerImageView: UIImageView!
  
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/wkyZK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wkyZK.png" alt="enter image description here"></a></p>
  
  <p>But I don't see that image on my header. It just show an empty header.</p>