0

This maybe a duplicate post. But I haven't found any solution in the answers given in previous questions.

Basic checks from my side that I have done.

  1. No errors on the constraint that I have put on CollectionView and CollectionViewCell.
  2. When numberofitemsinsection is called, it always returns more than 0.
  3. Reusable identifier is tagged for both CollectionView and CollectionViewCell
  4. All links for ui objects are at place.
  5. CollectionViewCell size is set as default.

Some more information on my code.

class StickerGridCollectionViewController: UICollectionViewController{
    override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {

        return stickerPackList.count
    }

    override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        /*some code*/
        return cell
    }


    override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        /*some code*/
    }
}

I checked all the answers here, but didn't find my answer yet. Any clue why I might be getting this issue?

Update When I open debug view hierarchy, I find out that collectionview is taking correct area, but views which were supposed to be inside collectionview are flowing outside and acting abnormally.

Moreover I see UICollectionView inside UiCollectionView. Any reason, why this abnormal behaviour might occur?screenshot of view debug hierarchy

Kaushik Nath
  • 106
  • 1
  • 11
  • Check if you putted the DataSource and the Delegate of the UICollectionView to your class. – Nekak Kinich Mar 13 '19 at 18:50
  • So, what is the `bounds` of the collection view? The only time I’ve seen that behavior is when there is a `bounds.size` of `.zero`. So, run the app from Xcode and then hit the “debug view hierarchy” button. – Rob Mar 13 '19 at 18:58
  • 1
    But we really need [MCVE](https://stackoverflow.com/help/mcve) to help you further. We obviously cannot reproduce your problem with the code provided thus far. (Nor do we want to see all of your code, just the bare minimum that we can add to a blank project to reproduce your behavior.) – Rob Mar 13 '19 at 19:01
  • It could be a Xcode glitch. **Troubleshooting steps:** Delete app -> Restart the simulator -> Clean build folder -> Rebuild -> Run. You can also try running in different simulator first to save time. – Bhaumik Mar 13 '19 at 19:01

0 Answers0