0

I am trying to make below effect using UICollectionView and its working fine.

enter image description here

However when I scroll left and right sometimes left or right cell is hiding. I can't see 3 rows, I just see 2 rows. Either left or right gets hided something like below.

enter image description here

I know the solution for this is collectionview.clipsToBounds = false, however cells are getting hided.

override func viewWillLayoutSubviews() {
    print("viewWillLayoutSubviews")
    hotelsCV.clipsToBounds = false
}

Any idea what I am doing wrong?

Below is my collection view frame.

enter image description here

Any idea what I am doing wrong?

Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276
  • i can't see whats wrong in the pictures can you point out which one – Mohmmad S Oct 25 '18 at 06:58
  • Personally, I've been through the pain of implementing collection views as you're doing, and I recommend using https://github.com/WenchaoD/FSPagerView which will save you a lot of time doing it yourself. But if you do want to do it yourself, you'll need to enlarge the collection view frame to be full screen, and configure scrollview delegate methods, etc. etc. See https://medium.com/@shaibalassiano/tutorial-horizontal-uicollectionview-with-paging-9421b479ee94 – cohen72 Oct 25 '18 at 07:00
  • @Tobi : Check second image... I have updated question – Fahim Parkar Oct 25 '18 at 07:14
  • @Tobi : Any update? did you see the issue? – Fahim Parkar Oct 25 '18 at 08:44
  • @FahimParkar yes i did, i have other things in my hands but asap as i can answer i will if someone didn't help by then – Mohmmad S Oct 25 '18 at 08:45
  • @MohmmadS : Did you have solution for this? – Fahim Parkar Nov 09 '21 at 05:52

1 Answers1

0

Hope this will resolve your issue.

override func viewWillAppear(_ animated: Bool) {
        self.edgesForExtendedLayout = []
} 
Rushabh Shah
  • 396
  • 3
  • 19
  • This doesn't fix for me – Fahim Parkar Oct 25 '18 at 07:50
  • can you explain more what this will do? – Fahim Parkar Oct 25 '18 at 07:50
  • If you remove an edge value from this property, the system does not lay out your content underneath other bars on that same edge. In addition, the system provides a default background so that translucent bars have an appropriate appearance. The window’s root view controller does not react to this property. You can refer it in Apple's official documentation [here](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621515-edgesforextendedlayout) – Rushabh Shah Oct 25 '18 at 08:07