UICollectionViewController Error in Swift 3.0: must be initialized with a non-nil layout parameter
<p>I'm new to iOS development.
I've been learning Swift, and today, I tried using UICollectionViewController.</p>

<p>My code is as follows:</p>

<pre><code> class ViewController: UICollectionViewController, UICollectionViewDelegateFlowLayout {
    var colView: UICollectionView!

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
        layout.sectionInset = UIEdgeInsets(top: 20, left: 10, bottom: 10, right: 10)
        layout.itemSize = CGSize(width: 90, height: 120)

        colView = UICollectionView(frame: self.view.frame, collectionViewLayout: layout)
        colView.dataSource = self
        colView.delegate = self
        colView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "Cell")
        colView.backgroundColor = UIColor.white
        self.view.addSubview(colView)
    }

    func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
        return 14
    }

    func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -&gt; UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath as IndexPath)
        cell.backgroundColor = UIColor.orange
        return cell
    }


}
</code></pre>

<p>However, when I try to run it, I get the following error:</p>

<pre><code>*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'UICollectionView must be initialized with a non-nil layout parameter'
</code></pre>

<p>I have looked up previous posts discussing this issue, but I couldn't find anything that fixed my code.</p>

<p>How should I fix this?</p>