mirror of
https://github.com/zhigang1992/SVPullToRefresh.git
synced 2026-01-12 17:52:46 +08:00
Initial commit.
This commit is contained in:
20
.gitignore
vendored
Normal file
20
.gitignore
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
# Mac OS X
|
||||
*.DS_Store
|
||||
*.psd
|
||||
|
||||
# Xcode
|
||||
*.pbxuser
|
||||
*.mode1v3
|
||||
*.mode2v3
|
||||
*.perspectivev3
|
||||
*.xcuserstate
|
||||
project.xcworkspace/
|
||||
xcuserdata/
|
||||
|
||||
# Generated files
|
||||
build/
|
||||
*.[oa]
|
||||
*.pyc
|
||||
|
||||
# Backup files
|
||||
*~.nib
|
||||
312
Demo/SVPullToRefreshDemo.xcodeproj/project.pbxproj
Normal file
312
Demo/SVPullToRefreshDemo.xcodeproj/project.pbxproj
Normal file
@@ -0,0 +1,312 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
22E0D9191545EE5B00BB6BB5 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22E0D9181545EE5B00BB6BB5 /* UIKit.framework */; };
|
||||
22E0D91B1545EE5B00BB6BB5 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22E0D91A1545EE5B00BB6BB5 /* Foundation.framework */; };
|
||||
22E0D91D1545EE5B00BB6BB5 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22E0D91C1545EE5B00BB6BB5 /* CoreGraphics.framework */; };
|
||||
22E0D9231545EE5B00BB6BB5 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 22E0D9211545EE5B00BB6BB5 /* InfoPlist.strings */; };
|
||||
22E0D9251545EE5B00BB6BB5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 22E0D9241545EE5B00BB6BB5 /* main.m */; };
|
||||
22E0D9291545EE5B00BB6BB5 /* SVAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 22E0D9281545EE5B00BB6BB5 /* SVAppDelegate.m */; };
|
||||
22E0D92C1545EE5B00BB6BB5 /* SVViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 22E0D92B1545EE5B00BB6BB5 /* SVViewController.m */; };
|
||||
22E0D92F1545EE5B00BB6BB5 /* SVViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 22E0D92D1545EE5B00BB6BB5 /* SVViewController.xib */; };
|
||||
22E0D93D1545EE7600BB6BB5 /* SVPullToRefresh.m in Sources */ = {isa = PBXBuildFile; fileRef = 22E0D93B1545EE7600BB6BB5 /* SVPullToRefresh.m */; };
|
||||
22E0D93E1545EE7600BB6BB5 /* SVPullToRefresh.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 22E0D93C1545EE7600BB6BB5 /* SVPullToRefresh.bundle */; };
|
||||
22E0D9411545EE9000BB6BB5 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22E0D9401545EE9000BB6BB5 /* QuartzCore.framework */; };
|
||||
22E0D94B1545F63300BB6BB5 /* README.textile in Resources */ = {isa = PBXBuildFile; fileRef = 22E0D94A1545F63300BB6BB5 /* README.textile */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
22E0D9141545EE5B00BB6BB5 /* SVPullToRefreshDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SVPullToRefreshDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
22E0D9181545EE5B00BB6BB5 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
||||
22E0D91A1545EE5B00BB6BB5 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
22E0D91C1545EE5B00BB6BB5 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
|
||||
22E0D9201545EE5B00BB6BB5 /* SVPullToRefreshDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SVPullToRefreshDemo-Info.plist"; sourceTree = "<group>"; };
|
||||
22E0D9221545EE5B00BB6BB5 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
22E0D9241545EE5B00BB6BB5 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
22E0D9261545EE5B00BB6BB5 /* SVPullToRefreshDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SVPullToRefreshDemo-Prefix.pch"; sourceTree = "<group>"; };
|
||||
22E0D9271545EE5B00BB6BB5 /* SVAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVAppDelegate.h; sourceTree = "<group>"; };
|
||||
22E0D9281545EE5B00BB6BB5 /* SVAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SVAppDelegate.m; sourceTree = "<group>"; };
|
||||
22E0D92A1545EE5B00BB6BB5 /* SVViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVViewController.h; sourceTree = "<group>"; };
|
||||
22E0D92B1545EE5B00BB6BB5 /* SVViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SVViewController.m; sourceTree = "<group>"; };
|
||||
22E0D92E1545EE5B00BB6BB5 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/SVViewController.xib; sourceTree = "<group>"; };
|
||||
22E0D93A1545EE7600BB6BB5 /* SVPullToRefresh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVPullToRefresh.h; sourceTree = "<group>"; };
|
||||
22E0D93B1545EE7600BB6BB5 /* SVPullToRefresh.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVPullToRefresh.m; sourceTree = "<group>"; };
|
||||
22E0D93C1545EE7600BB6BB5 /* SVPullToRefresh.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = SVPullToRefresh.bundle; sourceTree = "<group>"; };
|
||||
22E0D9401545EE9000BB6BB5 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
|
||||
22E0D94A1545F63300BB6BB5 /* README.textile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = README.textile; path = ../README.textile; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
22E0D9111545EE5B00BB6BB5 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
22E0D9411545EE9000BB6BB5 /* QuartzCore.framework in Frameworks */,
|
||||
22E0D9191545EE5B00BB6BB5 /* UIKit.framework in Frameworks */,
|
||||
22E0D91B1545EE5B00BB6BB5 /* Foundation.framework in Frameworks */,
|
||||
22E0D91D1545EE5B00BB6BB5 /* CoreGraphics.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
22E0D9091545EE5B00BB6BB5 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
22E0D94A1545F63300BB6BB5 /* README.textile */,
|
||||
22E0D91E1545EE5B00BB6BB5 /* Demo */,
|
||||
22E0D9391545EE7600BB6BB5 /* SVPullToRefresh */,
|
||||
22E0D9171545EE5B00BB6BB5 /* Frameworks */,
|
||||
22E0D9151545EE5B00BB6BB5 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
22E0D9151545EE5B00BB6BB5 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
22E0D9141545EE5B00BB6BB5 /* SVPullToRefreshDemo.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
22E0D9171545EE5B00BB6BB5 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
22E0D9401545EE9000BB6BB5 /* QuartzCore.framework */,
|
||||
22E0D9181545EE5B00BB6BB5 /* UIKit.framework */,
|
||||
22E0D91A1545EE5B00BB6BB5 /* Foundation.framework */,
|
||||
22E0D91C1545EE5B00BB6BB5 /* CoreGraphics.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
22E0D91E1545EE5B00BB6BB5 /* Demo */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
22E0D9271545EE5B00BB6BB5 /* SVAppDelegate.h */,
|
||||
22E0D9281545EE5B00BB6BB5 /* SVAppDelegate.m */,
|
||||
22E0D92A1545EE5B00BB6BB5 /* SVViewController.h */,
|
||||
22E0D92B1545EE5B00BB6BB5 /* SVViewController.m */,
|
||||
22E0D92D1545EE5B00BB6BB5 /* SVViewController.xib */,
|
||||
22E0D91F1545EE5B00BB6BB5 /* Supporting Files */,
|
||||
);
|
||||
name = Demo;
|
||||
path = SVPullToRefreshDemo;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
22E0D91F1545EE5B00BB6BB5 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
22E0D9201545EE5B00BB6BB5 /* SVPullToRefreshDemo-Info.plist */,
|
||||
22E0D9211545EE5B00BB6BB5 /* InfoPlist.strings */,
|
||||
22E0D9241545EE5B00BB6BB5 /* main.m */,
|
||||
22E0D9261545EE5B00BB6BB5 /* SVPullToRefreshDemo-Prefix.pch */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
22E0D9391545EE7600BB6BB5 /* SVPullToRefresh */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
22E0D93A1545EE7600BB6BB5 /* SVPullToRefresh.h */,
|
||||
22E0D93B1545EE7600BB6BB5 /* SVPullToRefresh.m */,
|
||||
22E0D93C1545EE7600BB6BB5 /* SVPullToRefresh.bundle */,
|
||||
);
|
||||
name = SVPullToRefresh;
|
||||
path = ../SVPullToRefresh;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
22E0D9131545EE5B00BB6BB5 /* SVPullToRefreshDemo */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 22E0D9321545EE5B00BB6BB5 /* Build configuration list for PBXNativeTarget "SVPullToRefreshDemo" */;
|
||||
buildPhases = (
|
||||
22E0D9101545EE5B00BB6BB5 /* Sources */,
|
||||
22E0D9111545EE5B00BB6BB5 /* Frameworks */,
|
||||
22E0D9121545EE5B00BB6BB5 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = SVPullToRefreshDemo;
|
||||
productName = SVPullToRefreshDemo;
|
||||
productReference = 22E0D9141545EE5B00BB6BB5 /* SVPullToRefreshDemo.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
22E0D90B1545EE5B00BB6BB5 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
CLASSPREFIX = SV;
|
||||
LastUpgradeCheck = 0430;
|
||||
ORGANIZATIONNAME = Home;
|
||||
};
|
||||
buildConfigurationList = 22E0D90E1545EE5B00BB6BB5 /* Build configuration list for PBXProject "SVPullToRefreshDemo" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = 22E0D9091545EE5B00BB6BB5;
|
||||
productRefGroup = 22E0D9151545EE5B00BB6BB5 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
22E0D9131545EE5B00BB6BB5 /* SVPullToRefreshDemo */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
22E0D9121545EE5B00BB6BB5 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
22E0D9231545EE5B00BB6BB5 /* InfoPlist.strings in Resources */,
|
||||
22E0D92F1545EE5B00BB6BB5 /* SVViewController.xib in Resources */,
|
||||
22E0D93E1545EE7600BB6BB5 /* SVPullToRefresh.bundle in Resources */,
|
||||
22E0D94B1545F63300BB6BB5 /* README.textile in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
22E0D9101545EE5B00BB6BB5 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
22E0D9251545EE5B00BB6BB5 /* main.m in Sources */,
|
||||
22E0D9291545EE5B00BB6BB5 /* SVAppDelegate.m in Sources */,
|
||||
22E0D92C1545EE5B00BB6BB5 /* SVViewController.m in Sources */,
|
||||
22E0D93D1545EE7600BB6BB5 /* SVPullToRefresh.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
22E0D9211545EE5B00BB6BB5 /* InfoPlist.strings */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
22E0D9221545EE5B00BB6BB5 /* en */,
|
||||
);
|
||||
name = InfoPlist.strings;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
22E0D92D1545EE5B00BB6BB5 /* SVViewController.xib */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
22E0D92E1545EE5B00BB6BB5 /* en */,
|
||||
);
|
||||
name = SVViewController.xib;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
22E0D9301545EE5B00BB6BB5 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
|
||||
SDKROOT = iphoneos;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
22E0D9311545EE5B00BB6BB5 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
|
||||
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
|
||||
SDKROOT = iphoneos;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
22E0D9331545EE5B00BB6BB5 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "SVPullToRefreshDemo/SVPullToRefreshDemo-Prefix.pch";
|
||||
INFOPLIST_FILE = "SVPullToRefreshDemo/SVPullToRefreshDemo-Info.plist";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
22E0D9341545EE5B00BB6BB5 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "SVPullToRefreshDemo/SVPullToRefreshDemo-Prefix.pch";
|
||||
INFOPLIST_FILE = "SVPullToRefreshDemo/SVPullToRefreshDemo-Info.plist";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
22E0D90E1545EE5B00BB6BB5 /* Build configuration list for PBXProject "SVPullToRefreshDemo" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
22E0D9301545EE5B00BB6BB5 /* Debug */,
|
||||
22E0D9311545EE5B00BB6BB5 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
22E0D9321545EE5B00BB6BB5 /* Build configuration list for PBXNativeTarget "SVPullToRefreshDemo" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
22E0D9331545EE5B00BB6BB5 /* Debug */,
|
||||
22E0D9341545EE5B00BB6BB5 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 22E0D90B1545EE5B00BB6BB5 /* Project object */;
|
||||
}
|
||||
19
Demo/SVPullToRefreshDemo/SVAppDelegate.h
Normal file
19
Demo/SVPullToRefreshDemo/SVAppDelegate.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// SVAppDelegate.h
|
||||
// SVPullToRefreshDemo
|
||||
//
|
||||
// Created by Sam Vermette on 23.04.12.
|
||||
// Copyright (c) 2012 samvermette.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class SVViewController;
|
||||
|
||||
@interface SVAppDelegate : UIResponder <UIApplicationDelegate>
|
||||
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
|
||||
@property (strong, nonatomic) SVViewController *viewController;
|
||||
|
||||
@end
|
||||
55
Demo/SVPullToRefreshDemo/SVAppDelegate.m
Normal file
55
Demo/SVPullToRefreshDemo/SVAppDelegate.m
Normal file
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// SVAppDelegate.m
|
||||
// SVPullToRefreshDemo
|
||||
//
|
||||
// Created by Sam Vermette on 23.04.12.
|
||||
// Copyright (c) 2012 samvermette.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SVAppDelegate.h"
|
||||
|
||||
#import "SVViewController.h"
|
||||
|
||||
@implementation SVAppDelegate
|
||||
|
||||
@synthesize window = _window;
|
||||
@synthesize viewController = _viewController;
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
// Override point for customization after application launch.
|
||||
self.viewController = [[SVViewController alloc] initWithNibName:@"SVViewController" bundle:nil];
|
||||
self.window.rootViewController = self.viewController;
|
||||
[self.window makeKeyAndVisible];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)applicationWillResignActive:(UIApplication *)application
|
||||
{
|
||||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
}
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application
|
||||
{
|
||||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application
|
||||
{
|
||||
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application
|
||||
{
|
||||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application
|
||||
{
|
||||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
||||
}
|
||||
|
||||
@end
|
||||
38
Demo/SVPullToRefreshDemo/SVPullToRefreshDemo-Info.plist
Normal file
38
Demo/SVPullToRefreshDemo/SVPullToRefreshDemo-Info.plist
Normal file
@@ -0,0 +1,38 @@
|
||||
<?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>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.samvermette.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
14
Demo/SVPullToRefreshDemo/SVPullToRefreshDemo-Prefix.pch
Normal file
14
Demo/SVPullToRefreshDemo/SVPullToRefreshDemo-Prefix.pch
Normal file
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Prefix header for all source files of the 'SVPullToRefreshDemo' target in the 'SVPullToRefreshDemo' project
|
||||
//
|
||||
|
||||
#import <Availability.h>
|
||||
|
||||
#ifndef __IPHONE_4_0
|
||||
#warning "This project uses features only available in iOS SDK 4.0 and later."
|
||||
#endif
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
15
Demo/SVPullToRefreshDemo/SVViewController.h
Normal file
15
Demo/SVPullToRefreshDemo/SVViewController.h
Normal file
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// SVViewController.h
|
||||
// SVPullToRefreshDemo
|
||||
//
|
||||
// Created by Sam Vermette on 23.04.12.
|
||||
// Copyright (c) 2012 samvermette.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface SVViewController : UIViewController
|
||||
|
||||
@property (nonatomic, strong) IBOutlet UITableView *tableView;
|
||||
|
||||
@end
|
||||
57
Demo/SVPullToRefreshDemo/SVViewController.m
Normal file
57
Demo/SVPullToRefreshDemo/SVViewController.m
Normal file
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// SVViewController.m
|
||||
// SVPullToRefreshDemo
|
||||
//
|
||||
// Created by Sam Vermette on 23.04.12.
|
||||
// Copyright (c) 2012 Home. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SVViewController.h"
|
||||
#import "SVPullToRefresh.h"
|
||||
|
||||
@interface SVViewController () <UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@end
|
||||
|
||||
@implementation SVViewController
|
||||
|
||||
@synthesize tableView;
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
[self.tableView addPullToRefreshWithActionHandler:^{
|
||||
NSLog(@"refresh dataSource");
|
||||
[tableView.pullToRefreshView performSelector:@selector(stopAnimating) withObject:nil afterDelay:2];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark UITableViewDataSource
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||
return 10;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return 4;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
|
||||
static NSString *identifier = @"Cell";
|
||||
|
||||
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:identifier];
|
||||
|
||||
if (cell == nil)
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
|
||||
|
||||
// Configure the cell.
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
|
||||
return [NSString stringWithFormat:@"Section %i", section];
|
||||
}
|
||||
|
||||
@end
|
||||
2
Demo/SVPullToRefreshDemo/en.lproj/InfoPlist.strings
Normal file
2
Demo/SVPullToRefreshDemo/en.lproj/InfoPlist.strings
Normal file
@@ -0,0 +1,2 @@
|
||||
/* Localized versions of Info.plist keys */
|
||||
|
||||
192
Demo/SVPullToRefreshDemo/en.lproj/SVViewController.xib
Normal file
192
Demo/SVPullToRefreshDemo/en.lproj/SVViewController.xib
Normal file
@@ -0,0 +1,192 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">1296</int>
|
||||
<string key="IBDocument.SystemVersion">11D50b</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">2182</string>
|
||||
<string key="IBDocument.AppKitVersion">1138.32</string>
|
||||
<string key="IBDocument.HIToolboxVersion">568.00</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="NS.object.0">1179</string>
|
||||
</object>
|
||||
<array key="IBDocument.IntegratedClassDependencies">
|
||||
<string>IBProxyObject</string>
|
||||
<string>IBUIView</string>
|
||||
<string>IBUITableView</string>
|
||||
</array>
|
||||
<array key="IBDocument.PluginDependencies">
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
</array>
|
||||
<object class="NSMutableDictionary" key="IBDocument.Metadata">
|
||||
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
|
||||
<integer value="1" key="NS.object.0"/>
|
||||
</object>
|
||||
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
|
||||
<object class="IBProxyObject" id="372490531">
|
||||
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
<object class="IBProxyObject" id="843779117">
|
||||
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
<object class="IBUIView" id="774585933">
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">274</int>
|
||||
<array class="NSMutableArray" key="NSSubviews">
|
||||
<object class="IBUITableView" id="215774682">
|
||||
<reference key="NSNextResponder" ref="774585933"/>
|
||||
<int key="NSvFlags">274</int>
|
||||
<string key="NSFrameSize">{320, 460}</string>
|
||||
<reference key="NSSuperview" ref="774585933"/>
|
||||
<reference key="NSWindow"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<object class="NSColor" key="IBUIBackgroundColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MQA</bytes>
|
||||
</object>
|
||||
<bool key="IBUIClipsSubviews">YES</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<bool key="IBUIAlwaysBounceVertical">YES</bool>
|
||||
<int key="IBUISeparatorStyle">1</int>
|
||||
<int key="IBUISectionIndexMinimumDisplayRowCount">0</int>
|
||||
<bool key="IBUIShowsSelectionImmediatelyOnTouchBegin">YES</bool>
|
||||
<float key="IBUIRowHeight">44</float>
|
||||
<float key="IBUISectionHeaderHeight">22</float>
|
||||
<float key="IBUISectionFooterHeight">22</float>
|
||||
</object>
|
||||
</array>
|
||||
<string key="NSFrame">{{0, 20}, {320, 460}}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="215774682"/>
|
||||
<object class="NSColor" key="IBUIBackgroundColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MC43NQA</bytes>
|
||||
<object class="NSColorSpace" key="NSCustomColorSpace">
|
||||
<int key="NSID">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
|
||||
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
<array class="NSMutableArray" key="connectionRecords">
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">view</string>
|
||||
<reference key="source" ref="372490531"/>
|
||||
<reference key="destination" ref="774585933"/>
|
||||
</object>
|
||||
<int key="connectionID">7</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">tableView</string>
|
||||
<reference key="source" ref="372490531"/>
|
||||
<reference key="destination" ref="215774682"/>
|
||||
</object>
|
||||
<int key="connectionID">12</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">dataSource</string>
|
||||
<reference key="source" ref="215774682"/>
|
||||
<reference key="destination" ref="372490531"/>
|
||||
</object>
|
||||
<int key="connectionID">9</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">delegate</string>
|
||||
<reference key="source" ref="215774682"/>
|
||||
<reference key="destination" ref="372490531"/>
|
||||
</object>
|
||||
<int key="connectionID">10</int>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<array key="orderedObjects">
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">0</int>
|
||||
<array key="object" id="0"/>
|
||||
<reference key="children" ref="1000"/>
|
||||
<nil key="parent"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-1</int>
|
||||
<reference key="object" ref="372490531"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">File's Owner</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-2</int>
|
||||
<reference key="object" ref="843779117"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">6</int>
|
||||
<reference key="object" ref="774585933"/>
|
||||
<array class="NSMutableArray" key="children">
|
||||
<reference ref="215774682"/>
|
||||
</array>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">8</int>
|
||||
<reference key="object" ref="215774682"/>
|
||||
<reference key="parent" ref="774585933"/>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<dictionary class="NSMutableDictionary" key="flattenedProperties">
|
||||
<string key="-1.CustomClassName">SVViewController</string>
|
||||
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="-2.CustomClassName">UIResponder</string>
|
||||
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="8.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
|
||||
<nil key="activeLocalization"/>
|
||||
<dictionary class="NSMutableDictionary" key="localizations"/>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">12</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">SVViewController</string>
|
||||
<string key="superclassName">UIViewController</string>
|
||||
<object class="NSMutableDictionary" key="outlets">
|
||||
<string key="NS.key.0">tableView</string>
|
||||
<string key="NS.object.0">UITableView</string>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
|
||||
<string key="NS.key.0">tableView</string>
|
||||
<object class="IBToOneOutletInfo" key="NS.object.0">
|
||||
<string key="name">tableView</string>
|
||||
<string key="candidateClassName">UITableView</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">./Classes/SVViewController.h</string>
|
||||
</object>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<int key="IBDocument.localizationMode">0</int>
|
||||
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
|
||||
<real value="1296" key="NS.object.0"/>
|
||||
</object>
|
||||
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
|
||||
<int key="IBDocument.defaultPropertyAccessControl">3</int>
|
||||
<string key="IBCocoaTouchPluginVersion">1179</string>
|
||||
</data>
|
||||
</archive>
|
||||
18
Demo/SVPullToRefreshDemo/main.m
Normal file
18
Demo/SVPullToRefreshDemo/main.m
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// main.m
|
||||
// SVPullToRefreshDemo
|
||||
//
|
||||
// Created by Sam Vermette on 23.04.12.
|
||||
// Copyright (c) 2012 samvermette.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "SVAppDelegate.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([SVAppDelegate class]));
|
||||
}
|
||||
}
|
||||
7
LICENSE.txt
Normal file
7
LICENSE.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright (C) 2012 Sam Vermette
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
43
README.textile
Normal file
43
README.textile
Normal file
@@ -0,0 +1,43 @@
|
||||
h1. SVPullToRefresh
|
||||
|
||||
SVPullToRefresh allow you to easily add pull-to-refresh functionality to any UIScrollView subclass. Instead of depending on delegates and/or subclassing UIViewController, SVPullToRefresh extends UIScrollView with:
|
||||
|
||||
* a - (void)addPullToRefreshWithActionHandler:(void (^)(void))actionHandler method
|
||||
* a @pullToRefreshView@ property
|
||||
|
||||
h2. Installation
|
||||
|
||||
* Drag the @SVPullToRefresh/SVPullToRefresh@ folder into your project.
|
||||
* Add the *QuartzCore* framework to your project.
|
||||
* @#import "SVPullToRefresh.h"@
|
||||
|
||||
h2. Usage
|
||||
|
||||
(see sample Xcode project in @/Demo@)
|
||||
|
||||
Adding pull-to-refresh to a table view can be done with one single line of code:
|
||||
|
||||
<pre>
|
||||
[tableView addPullToRefreshWithActionHandler:^{
|
||||
// refresh data
|
||||
// call [tableView.pullToRefreshView stopAnimating] when done
|
||||
}];
|
||||
</pre>
|
||||
|
||||
h2. Customization
|
||||
|
||||
The SVPullToRefresh view can be customized with the following properties:
|
||||
|
||||
<pre>
|
||||
@property (nonatomic, strong) UIColor *arrowColor;
|
||||
@property (nonatomic, strong) UIColor *textColor;
|
||||
@property (nonatomic, readwrite) UIActivityIndicatorViewStyle activityIndicatorViewStyle;
|
||||
</pre>
|
||||
|
||||
h2. Under the hood
|
||||
|
||||
SVPullToRefresh extends UIScrollView by adding a new public method as well as a dynamic property (thanks @seb_morel!). It uses key-value observing to track the scrollView's contentOffset, which removes the need for the view to be linked to the UIScrollViewDelegate protocol.
|
||||
|
||||
h2. Credits
|
||||
|
||||
SVPullToRefresh is brought to you by "Sam Vermette":http://samvermette.com and "contributors to the project":https://github.com/samvermette/SVPullToRefresh/contributors. If you have feature suggestions or bug reports, feel free to help out by sending pull requests or by "creating new issues":https://github.com/samvermette/SVPullToRefresh/issues/new. If you're using SVPullToRefresh in your project, attribution would be nice. Big thanks to @seb_morel for his "Demistifying the Objective-C runtime":http://cocoaheadsmtl.s3.amazonaws.com/demistifying-runtime.pdf which permitted the high abstraction of this class.
|
||||
BIN
SVPullToRefresh/SVPullToRefresh.bundle/arrow.png
Normal file
BIN
SVPullToRefresh/SVPullToRefresh.bundle/arrow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
SVPullToRefresh/SVPullToRefresh.bundle/arrow@2x.png
Normal file
BIN
SVPullToRefresh/SVPullToRefresh.bundle/arrow@2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
31
SVPullToRefresh/SVPullToRefresh.h
Normal file
31
SVPullToRefresh/SVPullToRefresh.h
Normal file
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// SVPullToRefresh.h
|
||||
//
|
||||
// Created by Sam Vermette on 23.04.12.
|
||||
// Copyright (c) 2012 samvermette.com. All rights reserved.
|
||||
//
|
||||
// https://github.com/samvermette/SVPullToRefresh
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface SVPullToRefresh : UIView
|
||||
|
||||
@property (nonatomic, strong) UIColor *arrowColor;
|
||||
@property (nonatomic, strong) UIColor *textColor;
|
||||
@property (nonatomic, readwrite) UIActivityIndicatorViewStyle activityIndicatorViewStyle;
|
||||
|
||||
- (void)stopAnimating;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
// extends UIScrollView
|
||||
|
||||
@interface UIScrollView (SVPullToRefresh)
|
||||
|
||||
- (void)addPullToRefreshWithActionHandler:(void (^)(void))actionHandler;
|
||||
|
||||
@property (nonatomic, strong) SVPullToRefresh *pullToRefreshView;
|
||||
|
||||
@end
|
||||
234
SVPullToRefresh/SVPullToRefresh.m
Normal file
234
SVPullToRefresh/SVPullToRefresh.m
Normal file
@@ -0,0 +1,234 @@
|
||||
//
|
||||
// SVPullToRefresh.m
|
||||
//
|
||||
// Created by Sam Vermette on 23.04.12.
|
||||
// Copyright (c) 2012 samvermette.com. All rights reserved.
|
||||
//
|
||||
// https://github.com/samvermette/SVPullToRefresh
|
||||
//
|
||||
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import "SVPullToRefresh.h"
|
||||
|
||||
enum {
|
||||
SVPullToRefreshStateHidden = 1,
|
||||
SVPullToRefreshStateVisible,
|
||||
SVPullToRefreshStateTriggered,
|
||||
SVPullToRefreshStateLoading
|
||||
};
|
||||
|
||||
typedef NSUInteger SVPullToRefreshState;
|
||||
|
||||
|
||||
@interface SVPullToRefresh ()
|
||||
|
||||
- (id)initWithScrollView:(UIScrollView*)scrollView;
|
||||
- (void)rotateArrow:(float)degrees hide:(BOOL)hide;
|
||||
- (void)setScrollViewContentInset:(UIEdgeInsets)contentInset;
|
||||
- (void)scrollViewDidScroll:(CGPoint)contentOffset;
|
||||
|
||||
@property (nonatomic, copy) void (^actionHandler)(void);
|
||||
@property (nonatomic, readwrite) SVPullToRefreshState state;
|
||||
|
||||
@property (nonatomic, strong) UIImageView *arrow;
|
||||
@property (nonatomic, strong, readonly) UIImage *arrowImage;
|
||||
@property (nonatomic, strong) UIActivityIndicatorView *activityIndicatorView;
|
||||
@property (nonatomic, strong) UILabel *titleLabel;
|
||||
|
||||
@property (nonatomic, strong) UIScrollView *scrollView;
|
||||
@property (nonatomic, readwrite) UIEdgeInsets originalScrollViewContentInset;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation SVPullToRefresh
|
||||
|
||||
// public properties
|
||||
@synthesize actionHandler, arrowColor, textColor, activityIndicatorViewStyle;
|
||||
|
||||
@synthesize state;
|
||||
@synthesize scrollView = _scrollView;
|
||||
@synthesize arrow, arrowImage, activityIndicatorView, titleLabel, originalScrollViewContentInset;
|
||||
|
||||
- (id)initWithScrollView:(UIScrollView *)scrollView {
|
||||
self = [super initWithFrame:CGRectZero];
|
||||
self.scrollView = scrollView;
|
||||
[_scrollView addSubview:self];
|
||||
|
||||
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(ceil(self.superview.bounds.size.width*0.21+44), 20, 150, 20)];
|
||||
titleLabel.text = NSLocalizedString(@"Pull to refresh...",);
|
||||
titleLabel.font = [UIFont boldSystemFontOfSize:14];
|
||||
titleLabel.backgroundColor = [UIColor clearColor];
|
||||
[self addSubview:titleLabel];
|
||||
|
||||
// default styling values
|
||||
self.arrowColor = [UIColor grayColor];
|
||||
self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
|
||||
self.titleLabel.textColor = [UIColor darkGrayColor];
|
||||
|
||||
[self addSubview:self.arrow];
|
||||
|
||||
[scrollView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:nil];
|
||||
self.originalScrollViewContentInset = scrollView.contentInset;
|
||||
|
||||
self.state = SVPullToRefreshStateHidden;
|
||||
self.frame = CGRectMake(0, -60, scrollView.bounds.size.width, 60);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Getters
|
||||
|
||||
- (UIImageView *)arrow {
|
||||
if(!arrow) {
|
||||
arrow = [[UIImageView alloc] initWithImage:self.arrowImage];
|
||||
arrow.frame = CGRectMake(ceil(self.superview.bounds.size.width*0.21), 6, 22, 48);
|
||||
arrow.backgroundColor = [UIColor clearColor];
|
||||
}
|
||||
return arrow;
|
||||
}
|
||||
|
||||
- (UIImage *)arrowImage {
|
||||
CGRect rect = CGRectMake(0, 0, 22, 48);
|
||||
UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);
|
||||
|
||||
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||
[[UIColor clearColor] set];
|
||||
CGContextFillRect(context, rect);
|
||||
|
||||
[self.arrowColor set];
|
||||
CGContextTranslateCTM(context, 0, rect.size.height);
|
||||
CGContextScaleCTM(context, 1.0, -1.0);
|
||||
CGContextClipToMask(context, rect, [[UIImage imageNamed:@"SVPullToRefresh.bundle/arrow"] CGImage]);
|
||||
CGContextFillRect(context, rect);
|
||||
|
||||
UIImage *output = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
return output;
|
||||
}
|
||||
|
||||
- (UIActivityIndicatorView *)activityIndicatorView {
|
||||
if(!activityIndicatorView) {
|
||||
activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
|
||||
activityIndicatorView.hidesWhenStopped = YES;
|
||||
[self addSubview:activityIndicatorView];
|
||||
self.activityIndicatorView.center = self.arrow.center;
|
||||
}
|
||||
return activityIndicatorView;
|
||||
}
|
||||
|
||||
#pragma mark - Setters
|
||||
|
||||
- (void)setArrowColor:(UIColor *)newArrowColor {
|
||||
arrowColor = newArrowColor;
|
||||
self.arrow.image = self.arrowImage;
|
||||
}
|
||||
|
||||
- (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)viewStyle {
|
||||
self.activityIndicatorView.activityIndicatorViewStyle = viewStyle;
|
||||
}
|
||||
|
||||
- (void)setScrollViewContentInset:(UIEdgeInsets)contentInset {
|
||||
[UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
|
||||
self.scrollView.contentInset = contentInset;
|
||||
} completion:NULL];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
|
||||
if([keyPath isEqualToString:@"contentOffset"])
|
||||
[self scrollViewDidScroll:[[change valueForKey:NSKeyValueChangeNewKey] CGPointValue]];
|
||||
}
|
||||
|
||||
- (void)scrollViewDidScroll:(CGPoint)contentOffset {
|
||||
CGFloat scrollOffsetThreshold = self.frame.origin.y-self.originalScrollViewContentInset.top;
|
||||
|
||||
if(!self.scrollView.isDragging && self.state == SVPullToRefreshStateTriggered)
|
||||
self.state = SVPullToRefreshStateLoading;
|
||||
else if(contentOffset.y > scrollOffsetThreshold && contentOffset.y < -self.originalScrollViewContentInset.top && self.scrollView.isDragging && self.state != SVPullToRefreshStateLoading)
|
||||
self.state = SVPullToRefreshStateVisible;
|
||||
else if(contentOffset.y < scrollOffsetThreshold && self.scrollView.isDragging && self.state == SVPullToRefreshStateVisible)
|
||||
self.state = SVPullToRefreshStateTriggered;
|
||||
else if(contentOffset.y >= -self.originalScrollViewContentInset.top && self.state != SVPullToRefreshStateHidden)
|
||||
self.state = SVPullToRefreshStateHidden;
|
||||
}
|
||||
|
||||
- (void)stopAnimating {
|
||||
self.state = SVPullToRefreshStateHidden;
|
||||
}
|
||||
|
||||
- (void)setState:(SVPullToRefreshState)newState {
|
||||
state = newState;
|
||||
|
||||
switch (newState) {
|
||||
case SVPullToRefreshStateHidden:
|
||||
titleLabel.text = NSLocalizedString(@"Pull to refresh...",);
|
||||
[self.activityIndicatorView stopAnimating];
|
||||
[self setScrollViewContentInset:self.originalScrollViewContentInset];
|
||||
[self rotateArrow:0 hide:YES];
|
||||
break;
|
||||
|
||||
case SVPullToRefreshStateVisible:
|
||||
titleLabel.text = NSLocalizedString(@"Pull to refresh...",);
|
||||
[self.activityIndicatorView stopAnimating];
|
||||
[self setScrollViewContentInset:self.originalScrollViewContentInset];
|
||||
[self rotateArrow:0 hide:NO];
|
||||
break;
|
||||
|
||||
case SVPullToRefreshStateTriggered:
|
||||
titleLabel.text = NSLocalizedString(@"Release to refresh...",);
|
||||
[self rotateArrow:M_PI hide:NO];
|
||||
break;
|
||||
|
||||
case SVPullToRefreshStateLoading:
|
||||
titleLabel.text = NSLocalizedString(@"Loading...",);
|
||||
[self.activityIndicatorView startAnimating];
|
||||
[self setScrollViewContentInset:UIEdgeInsetsMake(self.frame.origin.y*-1+self.originalScrollViewContentInset.top, 0, 0, 0)];
|
||||
[self rotateArrow:0 hide:YES];
|
||||
if(actionHandler)
|
||||
actionHandler();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)rotateArrow:(float)degrees hide:(BOOL)hide {
|
||||
[UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
|
||||
self.arrow.layer.transform = CATransform3DMakeRotation(degrees, 0, 0, 1);
|
||||
self.arrow.layer.opacity = !hide;
|
||||
} completion:NULL];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#pragma mark - UIScrollView (SVPullToRefresh)
|
||||
#import <objc/runtime.h>
|
||||
|
||||
static char UIScrollViewPullToRefreshView;
|
||||
|
||||
@implementation UIScrollView (SVPullToRefresh)
|
||||
|
||||
@dynamic pullToRefreshView;
|
||||
|
||||
- (void)addPullToRefreshWithActionHandler:(void (^)(void))actionHandler {
|
||||
SVPullToRefresh *pullToRefreshView = [[SVPullToRefresh alloc] initWithScrollView:self];
|
||||
pullToRefreshView.actionHandler = actionHandler;
|
||||
self.pullToRefreshView = pullToRefreshView;
|
||||
}
|
||||
|
||||
- (void)setPullToRefreshView:(SVPullToRefresh *)pullToRefreshView {
|
||||
[self willChangeValueForKey:@"pullToRefreshView"];
|
||||
objc_setAssociatedObject(self, &UIScrollViewPullToRefreshView,
|
||||
pullToRefreshView,
|
||||
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
[self didChangeValueForKey:@"pullToRefreshView"];
|
||||
}
|
||||
|
||||
- (SVPullToRefresh *)pullToRefreshView {
|
||||
return objc_getAssociatedObject(self, &UIScrollViewPullToRefreshView);
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user