即使UICollectionView未满,也可以滚动它 [英] Make the UICollectionView scrollable even when its not full
问题描述
当视图中没有足够的单元格时,UICollectionView会默认禁用滚动。当发生这种情况时,我需要它在拉动时弹回到位置。我知道一个黑客,我可以用空表填充UICollectionView以启用滚动,但我希望会有一个稍微更流畅的例子
The UICollectionView disables scrolling by default when there is not enough cells in the view. When this occurs I need it to bounce back to position when pulled. Im am aware of a hack where I can fill the UICollectionView with empty tables to enable scrolling but I was hoping there would be a slightly more fluid example as
我不知道希望视图滚动,而是自动弹回到其位置。这是因为我在下面实现的效果如下所示。
I don't want the view to scroll but instead to automatically bounce back to its position. This is because of the effect I have implemented below as can see below.
当没有足够的细胞时,有没有办法实现这一点UICollectionView禁用滚动。
Is there a way to achieve this simply, when there is not enough cells in the UICollectionView the scroll is disabled.
推荐答案
试试这个:
self.collectionView.alwaysBounceVertical = YES;
这篇关于即使UICollectionView未满,也可以滚动它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!