Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9900D16D1ABEB2490077A6CB"
BuildableName = "SDCycleScrollView.app"
BlueprintName = "SDCycleScrollView"
ReferencedContainer = "container:SDCycleScrollView.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9900D1861ABEB2490077A6CB"
BuildableName = "SDCycleScrollViewTests.xctest"
BlueprintName = "SDCycleScrollViewTests"
ReferencedContainer = "container:SDCycleScrollView.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9900D16D1ABEB2490077A6CB"
BuildableName = "SDCycleScrollView.app"
BlueprintName = "SDCycleScrollView"
ReferencedContainer = "container:SDCycleScrollView.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9900D16D1ABEB2490077A6CB"
BuildableName = "SDCycleScrollView.app"
BlueprintName = "SDCycleScrollView"
ReferencedContainer = "container:SDCycleScrollView.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9900D16D1ABEB2490077A6CB"
BuildableName = "SDCycleScrollView.app"
BlueprintName = "SDCycleScrollView"
ReferencedContainer = "container:SDCycleScrollView.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>SDCycleScrollView.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>9900D16D1ABEB2490077A6CB</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>9900D1861ABEB2490077A6CB</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
8 changes: 7 additions & 1 deletion SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#define kCycleScrollViewInitialPageControlDotSize CGSizeMake(10, 10)

NSString * const ID = @"cycleCell";
static int const kMultiple = 100;

@interface SDCycleScrollView () <UICollectionViewDataSource, UICollectionViewDelegate>

Expand Down Expand Up @@ -67,6 +68,7 @@ - (instancetype)initWithFrame:(CGRect)frame

- (void)awakeFromNib
{
[super awakeFromNib];
[self initialization];
[self setupMainView];
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
}
Expand Down