Error: UICollectionView must be initialized with a non-nil layout parameter

前端 未结 2 848
隐瞒了意图╮
隐瞒了意图╮ 2020-12-20 17:54

I am trying to create a Facebook messenger like application from a youtube tutorial. I have a home page where the user click BarButton to open the chats. The Home page works

2条回答
  •  不知归路
    2020-12-20 18:27

    Probably when you present your ChatViewController you have something like:

    let chatVC = ChatViewController()

    But according to Apple doc:

    class UICollectionViewController

    When you initialize the controller, using the init(collectionViewLayout:) method, you specify the layout the collection view should have.

    So you need:

     let chatVC = ChatViewController(collectionViewLayout: UICollectionViewFlowLayout())
    

提交回复
热议问题