SDCycleScrollView
SDCycleScrollView copied to clipboard
makeScrollViewScrollToIndex 这个方法 是什么意思?大问题呀,算法有问题
看源码 为啥要进行传进来的index 的换算? 大家都没发现这个问题?
简单解决了,随便看看吧!重写了个方法makeScrollToIndex:
-
(void)makeScrollViewScrollToIndex:(NSInteger)index { if (self.autoScroll) { [self invalidateTimer]; } if (0 == _totalItemsCount) return;
[self makeScrollToIndex:index];
if (self.autoScroll) { [self setupTimer]; } }
-
(void)makeScrollToIndex:(NSInteger)targetIndex { if (self.infiniteLoop) { targetIndex = targetIndex%(_totalItemsCount/100); targetIndex = _totalItemsCount * 0.5 + targetIndex; if (targetIndex < [self currentIndex]) { [_mainView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:(_totalItemsCount * 0.5 -1) inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO]; } }else if (targetIndex >= _totalItemsCount){ return; } [_mainView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:targetIndex inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:YES]; }
好的 我自己改了源码 啊哈