0

I want to display a list of product descriptions inside collection view cells and I'm using dequee for that.

I want to make sure that it only scrolls horizontally and not vertically at all.

The cell's width is 180px and the total number of my items is different every time.

I have tried a lot but the scrollView doesn't extend it's width at all.

1

2 Answers 2

3

You should specify the layoutDirection property of your collection in viewDidLoad:

 if let flow =  collectionView?.collectionViewLayout as? UICollectionViewFlowLayout{
          flow.scrollDirection = .Horizontal
    }

or you can do this in Storyboard.

Sign up to request clarification or add additional context in comments.

2 Comments

Do I need to have UIScrollBar and then add collectionView as subView too?
No, you don't need it.I use a collectionViewController in my example.
0

For swift 5 and easy way to do it. Use auto layout

enter image description here

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.