UICollectionView - 滚动到下一页

2024-04-13

是否有机会使用 .UICollectionView 滚动到所需的项目。 scrollToItemAtIndexPath 并且不捕捉到项目本身,而是捕捉到项目所属的页面? (我启用了分页功能。)

Cheers


你需要创建NSIndexPath而不是滚动到该索引。

 //Mark: - Move to cell when view did appear

overload viewDidAppear() {


    let scrollIndex: NSIndexPath = NSIndexPath(forItem: dayIndex, inSection: monthSection)
    if (// Check you are in range of UIcollectionView's count) {
        //Scroll collectionview according to your requirement i.e UICollectionViewScrollPositionCenteredHorizontally or UICollectionViewScrollPosition.Left 
        self.YourCollectionView.scrollToItemAtIndexPath(scrollIndex, atScrollPosition: UICollectionViewScrollPositionCenteredHorizontally, animated: true)
    }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

UICollectionView - 滚动到下一页 的相关文章

随机推荐