UICollectionView does not scroll

前端 未结 3 2003
清酒与你
清酒与你 2020-12-13 17:18

I have a UICollectionView set up with a UICollectionViewDataSource that currently provides six items. These are fewer than needed to fill the scree

相关标签:
3条回答
  • 2020-12-13 17:46

    With storyboards in attributes inspector for collection view "Bounces" and "Bounces Vertically" should be checked.

    0 讨论(0)
  • 2020-12-13 17:47

    bounces, despite it's name, isn't the right property to set. You also need to set alwaysBounceVertical and / or alwaysBounceHorizontal. From the documentation:

    If this property is set to YES and bounces is YES, vertical dragging is allowed even if the content is smaller than the bounds of the scroll view. The default value is NO.


    Note the confusing name in IB .. https://stackoverflow.com/a/18391029/294884

    0 讨论(0)
  • 2020-12-13 17:51

    Setting the height of the UICollectionView to size of UIView will make your scrolling problem disabled. If the UICollectionView is 568 pixels tall then it will only ever need to scroll if it has more than 568 pixels worth of content in it. You should set it to the height of the view it is contained in (same as the width).

    Hope it helps you.

    0 讨论(0)
提交回复
热议问题