停止滚动之前阻止滚动UIViewCollection

时间:2019-02-06 16:35:22

标签: ios swift

我有UIViewCollection类。我需要阻止UIViewCollection并在终止滚动动画UIViewCollection之后解锁。这种方法效果很好,但是当我触摸屏幕时,滚动还没完成

func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { 
    collectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true)
} 

1 个答案:

答案 0 :(得分:0)

由于CollectionView继承自UIScrollView,因此可以设置属性 您认为合适时,collectionView.isScrollEnabled为true或false,但是在共享的代码中,我看到您想滚动到集合中的每个项目,就像书中的页面一样,对吗?要实现还有另一个称为分页的属性,您也可以将其设置为true或false,我相信可以像collectionView.isPagingEnabled = true或false一样,希望对您有所帮助