OGeek|极客世界-中国程序员成长平台

标题: ios - 如何禁用 UICollectionView 的手势滑动 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 09:55
标题: ios - 如何禁用 UICollectionView 的手势滑动

目前,我正在制作分页 UICollectionView。我想从 UICollectionView 禁用手势滑动效果,因为我要添加 UIPagerControl 来为分页 UICollectionView 设置动画。我不希望用户使用他们的手指移动到下一个屏幕而不是使用自定义 UIPageControl。



Best Answer-推荐答案


从 UIScrollView 继承的 UICollection 可以通过这种方式禁用用户的滚动:

myCollectionView.scrollEnabled = NO;

这是文档说明(UIScrollView class reference):

When scrolling is disabled, the scroll view does not accept touch events; it forwards them up the responder chain.

使用 UIPageControl 时,您可以使用 UIScrollView 方法以编程方式设置 UICollectionView 中的位置:

- (void)setContentOffsetCGPoint)contentOffset
                animatedBOOL)animated

关于ios - 如何禁用 UICollectionView 的手势滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26889702/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4