diff --git a/SDCycleScrollView.xcodeproj/project.xcworkspace/xcuserdata/lanfeng.xcuserdatad/UserInterfaceState.xcuserstate b/SDCycleScrollView.xcodeproj/project.xcworkspace/xcuserdata/lanfeng.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 00000000..2427e719 Binary files /dev/null and b/SDCycleScrollView.xcodeproj/project.xcworkspace/xcuserdata/lanfeng.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/SDCycleScrollView.xcodeproj/xcuserdata/lanfeng.xcuserdatad/xcschemes/SDCycleScrollView.xcscheme b/SDCycleScrollView.xcodeproj/xcuserdata/lanfeng.xcuserdatad/xcschemes/SDCycleScrollView.xcscheme new file mode 100644 index 00000000..f2074e38 --- /dev/null +++ b/SDCycleScrollView.xcodeproj/xcuserdata/lanfeng.xcuserdatad/xcschemes/SDCycleScrollView.xcscheme @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SDCycleScrollView.xcodeproj/xcuserdata/lanfeng.xcuserdatad/xcschemes/xcschememanagement.plist b/SDCycleScrollView.xcodeproj/xcuserdata/lanfeng.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 00000000..bf26e19e --- /dev/null +++ b/SDCycleScrollView.xcodeproj/xcuserdata/lanfeng.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,27 @@ + + + + + SchemeUserState + + SDCycleScrollView.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 9900D16D1ABEB2490077A6CB + + primary + + + 9900D1861ABEB2490077A6CB + + primary + + + + + diff --git a/SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.m b/SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.m index 1de4b5f2..da8f4387 100644 --- a/SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.m +++ b/SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.m @@ -39,6 +39,7 @@ #define kCycleScrollViewInitialPageControlDotSize CGSizeMake(10, 10) NSString * const ID = @"cycleCell"; +static int const kMultiple = 100; @interface SDCycleScrollView () @@ -67,6 +68,7 @@ - (instancetype)initWithFrame:(CGRect)frame - (void)awakeFromNib { + [super awakeFromNib]; [self initialization]; [self setupMainView]; } @@ -287,7 +289,7 @@ - (void)setImagePathsGroup:(NSArray *)imagePathsGroup _imagePathsGroup = imagePathsGroup; - _totalItemsCount = self.infiniteLoop ? self.imagePathsGroup.count * 100 : self.imagePathsGroup.count; + _totalItemsCount = self.infiniteLoop ? self.imagePathsGroup.count * kMultiple : self.imagePathsGroup.count; if (imagePathsGroup.count != 1) { self.mainView.scrollEnabled = YES; @@ -408,6 +410,10 @@ - (void)automaticScroll { if (0 == _totalItemsCount) return; int currentIndex = [self currentIndex]; + if (_infiniteLoop && (currentIndex != [self pageControlIndexWithCurrentCellIndex:currentIndex] + (kMultiple / 2) * (int)self.imagePathsGroup.count)) { + currentIndex = [self pageControlIndexWithCurrentCellIndex:currentIndex] + (kMultiple / 2) * (int)self.imagePathsGroup.count; + [_mainView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:currentIndex inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO]; + } int targetIndex = currentIndex + 1; [self scrollToIndex:targetIndex]; }