滚动到指定index接口在轮播图设置为无限循环的时候根本滚动不到指定的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]; }