简体   繁体   中英

How to Auto Scroll with Compositional Collection View?

在此处输入图像描述

I use Compositional CollectionView to create collectionview with 2 sections. The first section is Horizontal Section as the picture. 1 Group has 3 items ( 3 cells). 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. 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. 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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM