Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Pull-to-refresh #179

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?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>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>9E03858C-9E51-4650-BF55-515F91E7981C</string>
<key>IDESourceControlProjectName</key>
<string>SwipeViewExample</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>C663044A1215EDAE9BFEE2935FD16744DA3876FB</key>
<string>github.com:praveenaj/SwipeView.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>Examples/Controls Example/SwipeViewExample.xcodeproj</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>C663044A1215EDAE9BFEE2935FD16744DA3876FB</key>
<string>../../../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>github.com:praveenaj/SwipeView.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>C663044A1215EDAE9BFEE2935FD16744DA3876FB</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>C663044A1215EDAE9BFEE2935FD16744DA3876FB</string>
<key>IDESourceControlWCCName</key>
<string>SwipeView</string>
</dict>
</array>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0640"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "01FA7D20145B5FCC00D118DB"
BuildableName = "SwipeViewExample.app"
BlueprintName = "SwipeViewExample"
ReferencedContainer = "container:SwipeViewExample.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "01FA7D20145B5FCC00D118DB"
BuildableName = "SwipeViewExample.app"
BlueprintName = "SwipeViewExample"
ReferencedContainer = "container:SwipeViewExample.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "01FA7D20145B5FCC00D118DB"
BuildableName = "SwipeViewExample.app"
BlueprintName = "SwipeViewExample"
ReferencedContainer = "container:SwipeViewExample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "01FA7D20145B5FCC00D118DB"
BuildableName = "SwipeViewExample.app"
BlueprintName = "SwipeViewExample"
ReferencedContainer = "container:SwipeViewExample.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,22 @@
<?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>SwipeViewExample.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>01FA7D20145B5FCC00D118DB</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
20 changes: 20 additions & 0 deletions Examples/Paging Example/ExampleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ - (void)viewDidLoad

//configure swipeView
_swipeView.pagingEnabled = YES;
_swipeView.pullToRefresh = YES; // Adds UIRefreshControl
_swipeView.vertical = YES; // Must be vertical for UIRefreshControl to work
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
Expand Down Expand Up @@ -119,4 +121,22 @@ - (CGSize)swipeViewItemSize:(SwipeView *)swipeView
return self.swipeView.bounds.size;
}

/* Handler for UIRefreshControl */

-(void)swipeViewHandleRefresh:(SwipeView *)swipeView{

// Simulate network call delay
double delayInSeconds = 2;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
//execute the code after .5 seconds
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){

//once all the data has been fetched
//we should end the refresh animation by
//calling the endRefreshing Method of UIRefreshControl
[_swipeView.refreshControl endRefreshing];

});
}

@end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?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>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>9CFB8D13-FFE2-450A-9685-48CD60E86E22</string>
<key>IDESourceControlProjectName</key>
<string>SwipeViewExample</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>C663044A1215EDAE9BFEE2935FD16744DA3876FB</key>
<string>github.com:praveenaj/SwipeView.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>Examples/Paging Example/SwipeViewExample.xcodeproj</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>C663044A1215EDAE9BFEE2935FD16744DA3876FB</key>
<string>../../../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>github.com:praveenaj/SwipeView.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>C663044A1215EDAE9BFEE2935FD16744DA3876FB</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>C663044A1215EDAE9BFEE2935FD16744DA3876FB</string>
<key>IDESourceControlWCCName</key>
<string>SwipeView</string>
</dict>
</array>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?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>HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges</key>
<true/>
<key>SnapshotAutomaticallyBeforeSignificantChanges</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../../SwipeView/SwipeView.m"
timestampString = "460186802.31548"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "151"
endingLineNumber = "151"
landmarkName = "-initWithCoder:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../../SwipeView/SwipeView.m"
timestampString = "460186590.856026"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "108"
endingLineNumber = "108"
landmarkName = "-setUp"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../../SwipeView/SwipeView.m"
timestampString = "460186802.31548"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "289"
endingLineNumber = "289"
landmarkName = "-setVertical:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../../SwipeView/SwipeView.m"
timestampString = "460186802.31548"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "298"
endingLineNumber = "298"
landmarkName = "-setPullToRefresh:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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>SuppressBuildableAutocreation</key>
<dict>
<key>01308D8D13491C3500453707</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
5 changes: 3 additions & 2 deletions SwipeView/SwipeView.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ typedef NS_ENUM(NSUInteger, SwipeViewAlignment)
@property (nonatomic, readonly, getter = isScrolling) BOOL scrolling;
@property (nonatomic, assign) BOOL defersItemViewLoading;
@property (nonatomic, assign, getter = isVertical) BOOL vertical;

@property (nonatomic,strong) UIRefreshControl *refreshControl;
@property (nonatomic, strong) UIScrollView *scrollView;
- (void)reloadData;
- (void)reloadItemAtIndex:(NSInteger)index;
- (void)scrollByOffset:(CGFloat)offset duration:(NSTimeInterval)duration;
Expand Down Expand Up @@ -121,7 +122,7 @@ typedef NS_ENUM(NSUInteger, SwipeViewAlignment)
- (void)swipeViewDidEndScrollingAnimation:(SwipeView *)swipeView;
- (BOOL)swipeView:(SwipeView *)swipeView shouldSelectItemAtIndex:(NSInteger)index;
- (void)swipeView:(SwipeView *)swipeView didSelectItemAtIndex:(NSInteger)index;

- (void)swipeViewHandleRefresh:(SwipeView *)swipeView;
@end


Expand Down
Loading