即使 UICollectionView 未满,也可滚动 [英] Make the UICollectionView scrollable even when its not full

查看:17
本文介绍了即使 UICollectionView 未满,也可滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当视图中没有足够的单元格时,UICollectionView 默认禁用滚动.发生这种情况时,我需要它在拉动时弹回原位.我知道一个 hack,我可以用空表填充 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.

https://youtu.be/r75xB9-Mb4g

有没有办法简单地实现这一点,当 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆