[英]How to Auto Scroll with Compositional Collection View?
I use Compositional CollectionView to create collectionview with 2 sections.我使用 Compositional CollectionView 创建包含 2 个部分的 collectionview。 The first section is Horizontal Section as the picture.
如图所示,第一部分是水平部分。 1 Group has 3 items ( 3 cells).
1 组有 3 个项目(3 个单元格)。 I want to make auto-scroll for this.
我想为此进行自动滚动。 Please, Anyone help me.
请,任何人帮助我。 Thank you so much
太感谢了
I have a similar UI to yours, It's an infinite auto-scrolling collection view using compositional layout.我有一个和你类似的 UI,它是一个使用组合布局的无限自动滚动集合视图。 You could check My Demo Project for reference.
您可以查看我的演示项目以供参考。
When you use Compositional Layout to set up collection view, scrollViewDidScroll(_:)
and scrollViewDidEndDecelerating(_:)
won't be fired.当您使用 Compositional Layout 设置集合视图时,不会触发
scrollViewDidScroll(_:)
和scrollViewDidEndDecelerating(_:)
。 So we need to use所以我们需要使用
layout.visibleItemsInvalidationHandler = {
visibleItems, point, environment in
// Config auto scroll here
}
And remember to invalidate timer when user tap the collection view cell.并记住在用户点击集合视图单元格时使计时器无效。 Please see detailed code in the above link.
请参阅上面链接中的详细代码。
Hope this help :)希望这有帮助:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.