Why does UICollectionView log an error when the cells are fullscreen?

后端 未结 10 1365
悲&欢浪女
悲&欢浪女 2020-12-08 04:06

I have a UICollectionViewController using a UICollectionViewFlowLayout where my itemSize is the size of the UICollectionView

10条回答
  •  广开言路
    2020-12-08 05:03

    This way had worked for me perfectly!.

    I just subtracted the top and bottom insets from the view's height as said in that error.

    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        return CGSize(width: view.frame.width , height: view.frame.height - (view.safeAreaInsets.top + view.safeAreaInsets.bottom))
    }
    

    I hope it helps!

提交回复
热议问题