简体   繁体   English

iOS中的UICollectionView单元格滚动问题

[英]UICollectionView cell scrolling issue in ios

On reloading the UICollectionView some time CollectionView cell does not bounce back. 重新加载UICollectionView一段时间后,CollectionView单元不会反弹。 看到图像。 see the image collectionCell with title "Bgrawal ji Sourabh" should not be at this much distance from right side.It should have bounce. 请参阅标题为“ Bgrawal ji Sourabh”的图像收集单元,它与右侧的距离不应太远。它应该反弹。

尝试这个:

[self.collectionView scrollToItemAtIndexPath:yourDesiredIndexPath atScrollPosition:UICollectionViewScrollPositionCenteredVertically animated:NO];

Please add below code before when your reload your collectionView 重新加载collectionView之前,请添加以下代码

let indexes = NSIndexPath(forItem: 0, inSection: 0)
self.collectionViewSecond.scrollToItemAtIndexPath(indexes, atScrollPosition: .None, animated: false)

It's work for me hope work for you also! 对我来说这是工作,希望对您也一样!

在此处输入图片说明

Make sure you have enabled these two option in the CollectionView attribute Inspector ie Bounce on Scroll and Bounce on zoom this will allow the collectionView to give a bounce feed back on the scroll. 确保已在CollectionView attribute Inspector启用了这两个选项,即Bounce on Scroll Bounce on zoomBounce on zoom这将使collectionView在滚动上提供弹跳反馈。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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