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 - 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!!!
You can start with adding the content top of UICollectionView as a header and rest as cells of UICollectionView
An example is as follow