Wednesday, January 10, 2024
HomeiOS Developmentios - UICollectionView - scrolling not inside, however in complete display screen

ios – UICollectionView – scrolling not inside, however in complete display screen


I am constructing my first app in Swift. I’ve RestaurantViewController. Half of the display screen is stuffed by restaurant title, description, emblem, atd.
And below this I’ve UICollectionView(), stuffed with restaurant Coupons. All the things works high-quality, however I wanna disable scrolling INSIDE the CollectionView, and permit to scroll in whole web page – so when person scrolls in coupons, complete web page is scrolling down and subsequent coupons are confirmed.

How can I do it?

IMAGE – Display screen

IMAGE – I wanna this after scroll

Coupons are loaded by way of API, so they’re obtainable few moments after setupUI() and so forth.

My code inside setupUI():

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

I’m not utilizing Storyboard, simply all programmatically. Additionally with UIKit and SnapKit (exterior library)
My SnapKit code for create constraints in display screen:

...
couponsCollectionView!.snp.makeConstraints { make in
   make.prime.equalTo(couponsTitle.snp.backside).offset(0)
   make.left.equalTo(0)
   make.width.equalToSuperview()
   make.main.trailing.backside.equalToSuperview()
}
...

Thanks!!!



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments