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 added .DS_Store
Binary file not shown.
Binary file added ch11/.DS_Store
Binary file not shown.
Binary file added ch11/InfiniteScrollingExample/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0460"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ABC1C8B115AAD33E0033ECF0"
BuildableName = "iOS6InfiniteScrolling.app"
BlueprintName = "iOS6InfiniteScrolling"
ReferencedContainer = "container:iOS6InfiniteScrolling.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 = "ABC1C8B115AAD33E0033ECF0"
BuildableName = "iOS6InfiniteScrolling.app"
BlueprintName = "iOS6InfiniteScrolling"
ReferencedContainer = "container:iOS6InfiniteScrolling.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>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ABC1C8B115AAD33E0033ECF0"
BuildableName = "iOS6InfiniteScrolling.app"
BlueprintName = "iOS6InfiniteScrolling"
ReferencedContainer = "container:iOS6InfiniteScrolling.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ABC1C8B115AAD33E0033ECF0"
BuildableName = "iOS6InfiniteScrolling.app"
BlueprintName = "iOS6InfiniteScrolling"
ReferencedContainer = "container:iOS6InfiniteScrolling.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>iOS6InfiniteScrolling.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>ABC1C8B115AAD33E0033ECF0</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "1.0">
</Bucket>
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0460"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ABC1C8B115AAD33E0033ECF0"
BuildableName = "iOS6InfiniteScrolling.app"
BlueprintName = "iOS6InfiniteScrolling"
ReferencedContainer = "container:iOS6InfiniteScrolling.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 = "ABC1C8B115AAD33E0033ECF0"
BuildableName = "iOS6InfiniteScrolling.app"
BlueprintName = "iOS6InfiniteScrolling"
ReferencedContainer = "container:iOS6InfiniteScrolling.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>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ABC1C8B115AAD33E0033ECF0"
BuildableName = "iOS6InfiniteScrolling.app"
BlueprintName = "iOS6InfiniteScrolling"
ReferencedContainer = "container:iOS6InfiniteScrolling.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ABC1C8B115AAD33E0033ECF0"
BuildableName = "iOS6InfiniteScrolling.app"
BlueprintName = "iOS6InfiniteScrolling"
ReferencedContainer = "container:iOS6InfiniteScrolling.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>iOS6InfiniteScrolling.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>ABC1C8B115AAD33E0033ECF0</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ -(void) doRefresh {
double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
self.loading = NO;
self.loading = NO;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ - (void)viewDidLoad

self.refreshControl = [[UIRefreshControl alloc] init];
[self.refreshControl addTarget:self action:@selector(refreshedByPullingTable:) forControlEvents:UIControlEventValueChanged];
} else {
}
else
{

self.refreshHeaderView = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f - self.tableView.bounds.size.height, self.tableView.bounds.size.width, self.tableView.bounds.size.height)];

Expand All @@ -76,7 +78,7 @@ - (void)viewDidLoad
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if(self.searchDisplayController.searchResultsTableView == scrollView) return;

if(NSClassFromString(@"UIRefreshControl")) return;
if (self.refreshHeaderView.state == EGOOPullRefreshLoading) {
CGFloat offset = MAX(scrollView.contentOffset.y * -1, 0);
offset = MIN(offset, 60);
Expand All @@ -97,7 +99,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
if(self.searchDisplayController.searchResultsTableView == scrollView) return;
if(NSClassFromString(@"UIRefreshControl")) return;
if (scrollView.contentOffset.y <= - 65.0f && !self.loading) {
self.loading = YES;

Expand Down Expand Up @@ -136,6 +138,7 @@ -(void) loadMore {

-(void) setLoading:(BOOL)loading
{
if(NSClassFromString(@"UIRefreshControl")) return;
_loading = loading;

[UIView beginAnimations:nil context:NULL];
Expand Down Expand Up @@ -175,18 +178,22 @@ -(UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS

if(indexPath.section == self.numberOfSections) {

static NSString *CellIdentifier = @"LoadingCell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
UIActivityIndicatorView *newSpin = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[newSpin startAnimating];
[newSpin setFrame:CGRectMake( 15, 12, 20, 20) ];
[cell addSubview:newSpin];
}

static NSString *CellIdentifier = @"LoadingCell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
UIActivityIndicatorView *newSpin = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[newSpin startAnimating];
[newSpin setFrame:CGRectMake( 15, 12, 20, 20) ];
[newSpin setTag:101];
[cell addSubview:newSpin];
}

[(UIActivityIndicatorView *)[cell viewWithTag:101] startAnimating];


cell.textLabel.text = NSLocalizedString(@"Loading…", @"");
cell.textLabel.textColor = [UIColor colorWithRed:0 green:0 blue:0.5 alpha:1.0];
cell.textLabel.textAlignment = NSTextAlignmentCenter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="2809" systemVersion="11E53" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="3">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="3084" systemVersion="12D78" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="3">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="1884"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="2083"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
Expand Down Expand Up @@ -47,17 +47,9 @@
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="KL4-lq-2um" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="668" y="129"/>
<point key="canvasLocation" x="395" y="64"/>
</scene>
</scenes>
<classes>
<class className="MasterViewController" superclassName="PullToRefreshViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/MasterViewController.h"/>
</class>
<class className="PullToRefreshViewController" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/PullToRefreshViewController.h"/>
</class>
</classes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
Expand Down
Binary file added ch11/PullToRefreshExample/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "1.0">
</Bucket>
Loading