参考了一些案例,但是实现了滚动后item能回到屏幕中间,却不知道怎么实现无限循环滚动。利用scrollView的代理方法,虽然实现了循环滚动。但是这样子,就会令item滚动后回到屏幕中间这个功能失效。求大神支招!!!
高洛峰2017-04-18 09:43:21
I have to write my own answer again. Is it because I asked the question incorrectly that no one answered? All right! I'll finish it myself!
-(CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset withScrollingVelocity:(CGPoint)velocity
This method is generally used to determine the final position of the item. Modifying this method can achieve some adsorption effects. However, when encountering loop items, we usually achieve the loop effect through the delegate method of scrollView. However, through this method , because the contentOffset of the collectionView is changed, the above method cannot calculate the final location of the item. So what should we do to loop and scroll the item to the specified position?
Forgive me for using a very low method
-( NSInteger )collectionView:( UICollectionView *)collectionView numberOfItemsInSection:( NSInteger )section
{
return 10000;
}
Set the number of items, - -! The reason for the reuse mechanism is so we don’t have to worry about memory and performance issues! Please give me some advice if there is a better way...
PHP中文网2017-04-18 09:43:21
加头加尾
, for example, if there are four items, the actual item should be 6, that is, 412341. When manually scrolling to the back 1, the code will immediately slide (without animation effect) to the front 1, and the reverse direction is similar.