ios – UICollectionView – scrolling not inside, but in whole screen


I’m building my first app in Swift. I have RestaurantViewController. Half of the screen is filled by restaurant name, description, logo, atd.
And under this I have UICollectionView(), filled with restaurant Coupons. Everything works fine, but I wanna disable scrolling INSIDE the CollectionView, and allow to scroll in entire page – so when user scrolls in coupons, whole page is scrolling down and next coupons are showed.

How can I do it?

IMAGE – Screen

IMAGE – I wanna this after scroll

Coupons are loaded via API, so they are available few moments after setupUI() etc.

My code inside setupUI():

...
let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
self.couponsCollectionView = UICollectionView(frame: self.view.bounds, collectionViewLayout: layout)
couponsCollectionView!.register(UICollectionViewCell.self, forCellWithReuseIdentifier: CouponCollectionCell.reuseIdentifier)
couponsCollectionView!.alwaysBounceVertical = true
couponsCollectionView!.isScrollEnabled = false
...

I am not using Storyboard, just all programmatically. Also with UIKit and SnapKit (external library)
My SnapKit code for create constraints in screen:

...
couponsCollectionView!.snp.makeConstraints { make in
   make.top.equalTo(couponsTitle.snp.bottom).offset(0)
   make.left.equalTo(0)
   make.width.equalToSuperview()
   make.leading.trailing.bottom.equalToSuperview()
}
...

Thank you!!!

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img