title: Right way to add collection view without behaviour of the UICollectionViewFlowLayout is not defined warning
body: <p>My requirement is to have a slider collection view on top of my view in ViewController. I've tried many work around for my requirement (You can see that in my collection view setup code). But, time I receive the warning about <code>The behavior of the UICollectionViewFlowLayout is not defined</code>. The view controller is being called from controllers array inside of a <code>UITabBarController</code> which in turn is embedded in a <code>UINavigtionController</code>. The view controller contains a collection view of height 200. I want each cell of the collection view to expand its full width and height.</p>
  
  <p>Warning:</p>
  
  <pre><code>2017-09-06 12:05:19.139 collectionViewSample[3686:79491] The behavior of the UICollectionViewFlowLayout is not defined because:
  2017-09-06 12:05:19.139 collectionViewSample[3686:79491] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
  2017-09-06 12:05:19.140 collectionViewSample[3686:79491] The relevant UICollectionViewFlowLayout instance is &lt;UICollectionViewFlowLayout: 0x7ff4e4c00020&gt;, and it is attached to &lt;UICollectionView: 0x7ff4e5032600; frame = (0 64; 414 200); clipsToBounds = YES; gestureRecognizers = &lt;NSArray: 0x600000047290&gt;; layer = &lt;CALayer: 0x60000002d240&gt;; contentOffset: {0, -64}; contentSize: {0, 0}&gt; collection view layout: &lt;UICollectionViewFlowLayout: 0x7ff4e4c00020&gt;.
  2017-09-06 12:05:19.140 collectionViewSample[3686:79491] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
  </code></pre>
  
  <p>AppDelegate:</p>
  
  <pre><code>    window = UIWindow(frame: UIScreen.main.bounds)
      window?.makeKeyAndVisible()
      let mainController = UITabBarController()
      let navController = UINavigationController(rootViewController: ViewController())
      mainController.viewControllers = [navController]
      window?.rootViewController = mainController
  </code></pre>
  
  <p>ViewController:</p>
  
  <pre><code>class ViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      view.backgroundColor = .white
      setupCollectionView()
  }
  
  func setupCollectionView() {
  
      let layout = UICollectionViewFlowLayout()
      layout.scrollDirection = .horizontal
      let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
      collectionView.translatesAutoresizingMaskIntoConstraints = false
      collectionView.scrollIndicatorInsets = .zero
      collectionView.contentInset = .zero
      collectionView.preservesSuperviewLayoutMargins = false
      collectionView.layoutMargins = .zero
  
      collectionView.delegate = self
      collectionView.dataSource = self
      collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "cellId")
      view.addSubview(collectionView)
  
      collectionView.topAnchor.constraint(equalTo: topLayoutGuide.bottomAnchor).isActive = true
      collectionView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
      collectionView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
      collectionView.heightAnchor.constraint(equalToConstant: 200).isActive = true
  }
  
  func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellId", for: indexPath)
      cell.backgroundColor = .green
      return cell
  }
  
  func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
      return 2
  }
  
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -&gt; CGFloat {
      return 0
  }
  
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -&gt; CGFloat {
      return 0
  }
  
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -&gt; UIEdgeInsets {
      return UIEdgeInsetsMake(0, 0, 0, 0)
  }
  
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -&gt; CGSize {
      return CGSize(width: view.frame.width, height: 200)
  }
  }
  </code></pre>
  
  <p>When the cells are populated with image that fills the entire frame of the collection view it leaves a small gap on top from navigation bar. Collection view frame does extend to my requirements but the cells are not. How would I fix this the proper way?</p>