Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial commit

  • Loading branch information...
commit d3746f5e368864bf9b6ff34c666a0a1d5ce169b5 0 parents
Yosuke Ishikawa authored
2  .gitignore
@@ -0,0 +1,2 @@
+build
+Products
BIN  DemoApp/Default-568h@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  DemoApp/Default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  DemoApp/Default@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 DemoApp/DemoApp-Info.plist
@@ -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>-.${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 DemoApp/DemoApp-Prefix.pch
@@ -0,0 +1,14 @@
+//
+// Prefix header for all source files of the 'DemoApp' target in the 'DemoApp' project
+//
+
+#import <Availability.h>
+
+#ifndef __IPHONE_3_0
+#warning "This project uses features only available in iOS SDK 3.0 and later."
+#endif
+
+#ifdef __OBJC__
+ #import <UIKit/UIKit.h>
+ #import <Foundation/Foundation.h>
+#endif
7 DemoApp/ISAppDelegate.h
@@ -0,0 +1,7 @@
+#import <UIKit/UIKit.h>
+
+@interface ISAppDelegate : UIResponder <UIApplicationDelegate>
+
+@property (strong, nonatomic) UIWindow *window;
+
+@end
20 DemoApp/ISAppDelegate.m
@@ -0,0 +1,20 @@
+#import "ISAppDelegate.h"
+#import "ISDemoViewController.h"
+
+@implementation ISAppDelegate
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ ISDemoViewController *viewController = [[ISDemoViewController alloc] init];
+ UINavigationController *navigationController = [[UINavigationController alloc] init];
+ navigationController.viewControllers = @[viewController];
+
+ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+ self.window.backgroundColor = [UIColor whiteColor];
+ self.window.rootViewController = navigationController;
+ [self.window makeKeyAndVisible];
+
+ return YES;
+}
+
+@end
5 DemoApp/ISDemoViewController.h
@@ -0,0 +1,5 @@
+#import <UIKit/UIKit.h>
+
+@interface ISDemoViewController : UIViewController
+
+@end
63 DemoApp/ISDemoViewController.m
@@ -0,0 +1,63 @@
+#import "ISDemoViewController.h"
+#import "UIViewController+BackGesture.h"
+#import <objc/runtime.h>
+
+@implementation ISDemoViewController
+
+- (id)init
+{
+ self = [super init];
+ if (self) {
+ self.backGestureEnabled = YES;
+
+ [self addObserver:self forKeyPath:@"backProgress" options:0 context:NULL];
+ }
+ return self;
+}
+
+- (void)dealloc
+{
+ [self removeObserver:self forKeyPath:@"backProgress"];
+}
+
+- (void)loadView
+{
+ [super loadView];
+
+ UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
+ button.frame = CGRectMake(120, 200, 80, 40);
+ [button setTitle:@"Push" forState:UIControlStateNormal];
+ [button addTarget:self
+ action:@selector(push)
+ forControlEvents:UIControlEventTouchUpInside];
+
+ [self.view addSubview:button];
+}
+
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
+{
+ if (object == self && [keyPath isEqualToString:@"backProgress"]) {
+ NSString *title = [NSString stringWithFormat:@"%.2f", self.backProgress];
+
+ NSInteger index = [self.navigationController.viewControllers count] - 2;
+ if (index >= 0) {
+ UIViewController *viewController = [self.navigationController.viewControllers objectAtIndex:index];
+
+ viewController.navigationItem.backBarButtonItem =
+ [[UIBarButtonItem alloc] initWithTitle:title
+ style:UIBarButtonItemStyleBordered
+ target:nil
+ action:nil];
+ }
+ } else {
+ [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
+ }
+}
+
+- (void)push
+{
+ ISDemoViewController *viewController = [[ISDemoViewController alloc] init];
+ [self.navigationController pushViewController:viewController animated:YES];
+}
+
+@end
2  DemoApp/en.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+
18 DemoApp/main.m
@@ -0,0 +1,18 @@
+//
+// main.m
+// DemoApp
+//
+// Created by Yosuke Ishikawa on 2013/02/22.
+// Copyright (c) 2013年 Yosuke Ishikawa. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+#import "ISAppDelegate.h"
+
+int main(int argc, char *argv[])
+{
+ @autoreleasepool {
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass([ISAppDelegate class]));
+ }
+}
22 ISBackGesture.podspec
@@ -0,0 +1,22 @@
+Pod::Spec.new do |s|
+ s.name = "ISBackGesture"
+ s.version = "0.0.1"
+ s.summary = "equips UIViewController with recognizing swipe to back."
+ s.homepage = "https://github.com/ishkawa/ISBackGesture"
+ s.author = { "Yosuke Ishikawa" => "ishkawa73@gmail.com" }
+ s.source = { :git => "https://github.com/ishkawa/ISBackGesture.git", :tag => "0.0.1" }
+ s.platform = :ios, '4.0'
+ s.source_files = 'Classes', 'ISBackGesture/**/*.{h,m}'
+ s.license = {
+ :type => 'MIT',
+ :text => <<-LICENSE
+ Copyright (c) 2013 Yosuke Ishikawa
+
+ 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.
+ LICENSE
+ }
+end
415 ISBackGesture.xcodeproj/project.pbxproj
@@ -0,0 +1,415 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 7FA133A516D7309E008204B7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7FA133A416D7309E008204B7 /* Foundation.framework */; };
+ 7FA133AA16D7309E008204B7 /* ISBackGesture.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7FA133A916D7309E008204B7 /* ISBackGesture.h */; };
+ 7FB665FC16D7316100EF6380 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7FA133B716D730A6008204B7 /* UIKit.framework */; };
+ 7FB665FD16D7316100EF6380 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7FA133A416D7309E008204B7 /* Foundation.framework */; };
+ 7FB665FE16D7316100EF6380 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7FA133BA16D730A6008204B7 /* CoreGraphics.framework */; };
+ 7FB6660416D7316100EF6380 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 7FB6660216D7316100EF6380 /* InfoPlist.strings */; };
+ 7FB6660616D7316100EF6380 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 7FB6660516D7316100EF6380 /* main.m */; };
+ 7FB6660A16D7316100EF6380 /* ISAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7FB6660916D7316100EF6380 /* ISAppDelegate.m */; };
+ 7FB6660C16D7316100EF6380 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 7FB6660B16D7316100EF6380 /* Default.png */; };
+ 7FB6660E16D7316100EF6380 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7FB6660D16D7316100EF6380 /* Default@2x.png */; };
+ 7FB6661016D7316100EF6380 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7FB6660F16D7316100EF6380 /* Default-568h@2x.png */; };
+ 7FB6661716D7317100EF6380 /* libISBackGesture.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7FA133A116D7309E008204B7 /* libISBackGesture.a */; };
+ 7FB6661A16D731C200EF6380 /* ISDemoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7FB6661916D731C200EF6380 /* ISDemoViewController.m */; };
+ 7FB6662016D731D500EF6380 /* UIViewController+BackGesture.m in Sources */ = {isa = PBXBuildFile; fileRef = 7FB6661E16D731D500EF6380 /* UIViewController+BackGesture.m */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXContainerItemProxy section */
+ 7FB6661416D7316600EF6380 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 7FA1339916D7309E008204B7 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 7FA133A016D7309E008204B7;
+ remoteInfo = ISBackGesture;
+ };
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+ 7FA1339F16D7309E008204B7 /* CopyFiles */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = "include/${PRODUCT_NAME}";
+ dstSubfolderSpec = 16;
+ files = (
+ 7FA133AA16D7309E008204B7 /* ISBackGesture.h in CopyFiles */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+ 7FA133A116D7309E008204B7 /* libISBackGesture.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libISBackGesture.a; sourceTree = BUILT_PRODUCTS_DIR; };
+ 7FA133A416D7309E008204B7 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ 7FA133A916D7309E008204B7 /* ISBackGesture.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ISBackGesture.h; sourceTree = "<group>"; };
+ 7FA133B716D730A6008204B7 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
+ 7FA133BA16D730A6008204B7 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+ 7FB665FB16D7316100EF6380 /* DemoApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DemoApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 7FB6660116D7316100EF6380 /* DemoApp-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "DemoApp-Info.plist"; sourceTree = "<group>"; };
+ 7FB6660316D7316100EF6380 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ 7FB6660516D7316100EF6380 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ 7FB6660716D7316100EF6380 /* DemoApp-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "DemoApp-Prefix.pch"; sourceTree = "<group>"; };
+ 7FB6660816D7316100EF6380 /* ISAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ISAppDelegate.h; sourceTree = "<group>"; };
+ 7FB6660916D7316100EF6380 /* ISAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ISAppDelegate.m; sourceTree = "<group>"; };
+ 7FB6660B16D7316100EF6380 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = "<group>"; };
+ 7FB6660D16D7316100EF6380 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = "<group>"; };
+ 7FB6660F16D7316100EF6380 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
+ 7FB6661816D731C200EF6380 /* ISDemoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISDemoViewController.h; sourceTree = "<group>"; };
+ 7FB6661916D731C200EF6380 /* ISDemoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ISDemoViewController.m; sourceTree = "<group>"; };
+ 7FB6661D16D731D500EF6380 /* UIViewController+BackGesture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+BackGesture.h"; sourceTree = "<group>"; };
+ 7FB6661E16D731D500EF6380 /* UIViewController+BackGesture.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+BackGesture.m"; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 7FA1339E16D7309E008204B7 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 7FA133A516D7309E008204B7 /* Foundation.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 7FB665F816D7316100EF6380 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 7FB6661716D7317100EF6380 /* libISBackGesture.a in Frameworks */,
+ 7FB665FC16D7316100EF6380 /* UIKit.framework in Frameworks */,
+ 7FB665FD16D7316100EF6380 /* Foundation.framework in Frameworks */,
+ 7FB665FE16D7316100EF6380 /* CoreGraphics.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 7FA1339816D7309E008204B7 = {
+ isa = PBXGroup;
+ children = (
+ 7FA133A616D7309E008204B7 /* ISBackGesture */,
+ 7FB665FF16D7316100EF6380 /* DemoApp */,
+ 7FA133A316D7309E008204B7 /* Frameworks */,
+ 7FA133A216D7309E008204B7 /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ 7FA133A216D7309E008204B7 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 7FA133A116D7309E008204B7 /* libISBackGesture.a */,
+ 7FB665FB16D7316100EF6380 /* DemoApp.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 7FA133A316D7309E008204B7 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 7FA133A416D7309E008204B7 /* Foundation.framework */,
+ 7FA133B716D730A6008204B7 /* UIKit.framework */,
+ 7FA133BA16D730A6008204B7 /* CoreGraphics.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ 7FA133A616D7309E008204B7 /* ISBackGesture */ = {
+ isa = PBXGroup;
+ children = (
+ 7FA133A916D7309E008204B7 /* ISBackGesture.h */,
+ 7FB6661D16D731D500EF6380 /* UIViewController+BackGesture.h */,
+ 7FB6661E16D731D500EF6380 /* UIViewController+BackGesture.m */,
+ );
+ path = ISBackGesture;
+ sourceTree = "<group>";
+ };
+ 7FB665FF16D7316100EF6380 /* DemoApp */ = {
+ isa = PBXGroup;
+ children = (
+ 7FB6660816D7316100EF6380 /* ISAppDelegate.h */,
+ 7FB6660916D7316100EF6380 /* ISAppDelegate.m */,
+ 7FB6661816D731C200EF6380 /* ISDemoViewController.h */,
+ 7FB6661916D731C200EF6380 /* ISDemoViewController.m */,
+ 7FB6660016D7316100EF6380 /* Supporting Files */,
+ );
+ path = DemoApp;
+ sourceTree = "<group>";
+ };
+ 7FB6660016D7316100EF6380 /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ 7FB6660116D7316100EF6380 /* DemoApp-Info.plist */,
+ 7FB6660216D7316100EF6380 /* InfoPlist.strings */,
+ 7FB6660516D7316100EF6380 /* main.m */,
+ 7FB6660716D7316100EF6380 /* DemoApp-Prefix.pch */,
+ 7FB6660B16D7316100EF6380 /* Default.png */,
+ 7FB6660D16D7316100EF6380 /* Default@2x.png */,
+ 7FB6660F16D7316100EF6380 /* Default-568h@2x.png */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 7FA133A016D7309E008204B7 /* ISBackGesture */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 7FA133AF16D7309E008204B7 /* Build configuration list for PBXNativeTarget "ISBackGesture" */;
+ buildPhases = (
+ 7FA1339D16D7309E008204B7 /* Sources */,
+ 7FA1339E16D7309E008204B7 /* Frameworks */,
+ 7FA1339F16D7309E008204B7 /* CopyFiles */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = ISBackGesture;
+ productName = ISBackGesture;
+ productReference = 7FA133A116D7309E008204B7 /* libISBackGesture.a */;
+ productType = "com.apple.product-type.library.static";
+ };
+ 7FB665FA16D7316100EF6380 /* DemoApp */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 7FB6661116D7316100EF6380 /* Build configuration list for PBXNativeTarget "DemoApp" */;
+ buildPhases = (
+ 7FB665F716D7316100EF6380 /* Sources */,
+ 7FB665F816D7316100EF6380 /* Frameworks */,
+ 7FB665F916D7316100EF6380 /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ 7FB6661516D7316600EF6380 /* PBXTargetDependency */,
+ );
+ name = DemoApp;
+ productName = DemoApp;
+ productReference = 7FB665FB16D7316100EF6380 /* DemoApp.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 7FA1339916D7309E008204B7 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0460;
+ ORGANIZATIONNAME = "Yosuke Ishikawa";
+ };
+ buildConfigurationList = 7FA1339C16D7309E008204B7 /* Build configuration list for PBXProject "ISBackGesture" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = 7FA1339816D7309E008204B7;
+ productRefGroup = 7FA133A216D7309E008204B7 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 7FA133A016D7309E008204B7 /* ISBackGesture */,
+ 7FB665FA16D7316100EF6380 /* DemoApp */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 7FB665F916D7316100EF6380 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 7FB6660416D7316100EF6380 /* InfoPlist.strings in Resources */,
+ 7FB6660C16D7316100EF6380 /* Default.png in Resources */,
+ 7FB6660E16D7316100EF6380 /* Default@2x.png in Resources */,
+ 7FB6661016D7316100EF6380 /* Default-568h@2x.png in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 7FA1339D16D7309E008204B7 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 7FB6662016D731D500EF6380 /* UIViewController+BackGesture.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 7FB665F716D7316100EF6380 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 7FB6660616D7316100EF6380 /* main.m in Sources */,
+ 7FB6660A16D7316100EF6380 /* ISAppDelegate.m in Sources */,
+ 7FB6661A16D731C200EF6380 /* ISDemoViewController.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXTargetDependency section */
+ 7FB6661516D7316600EF6380 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 7FA133A016D7309E008204B7 /* ISBackGesture */;
+ targetProxy = 7FB6661416D7316600EF6380 /* PBXContainerItemProxy */;
+ };
+/* End PBXTargetDependency section */
+
+/* Begin PBXVariantGroup section */
+ 7FB6660216D7316100EF6380 /* InfoPlist.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 7FB6660316D7316100EF6380 /* en */,
+ );
+ name = InfoPlist.strings;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ 7FA133AD16D7309E008204B7 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ 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_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 6.1;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = iphoneos;
+ };
+ name = Debug;
+ };
+ 7FA133AE16D7309E008204B7 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 6.1;
+ SDKROOT = iphoneos;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ 7FA133B016D7309E008204B7 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ DSTROOT = /tmp/ISBackGesture.dst;
+ GCC_PRECOMPILE_PREFIX_HEADER = NO;
+ GCC_PREFIX_HEADER = "";
+ OTHER_LDFLAGS = "-ObjC";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SKIP_INSTALL = YES;
+ };
+ name = Debug;
+ };
+ 7FA133B116D7309E008204B7 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ DSTROOT = /tmp/ISBackGesture.dst;
+ GCC_PRECOMPILE_PREFIX_HEADER = NO;
+ GCC_PREFIX_HEADER = "";
+ OTHER_LDFLAGS = "-ObjC";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SKIP_INSTALL = YES;
+ };
+ name = Release;
+ };
+ 7FB6661216D7316100EF6380 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "DemoApp/DemoApp-Prefix.pch";
+ INFOPLIST_FILE = "DemoApp/DemoApp-Info.plist";
+ OTHER_LDFLAGS = "-ObjC";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Debug;
+ };
+ 7FB6661316D7316100EF6380 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "DemoApp/DemoApp-Prefix.pch";
+ INFOPLIST_FILE = "DemoApp/DemoApp-Info.plist";
+ OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
+ OTHER_LDFLAGS = "-ObjC";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 7FA1339C16D7309E008204B7 /* Build configuration list for PBXProject "ISBackGesture" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 7FA133AD16D7309E008204B7 /* Debug */,
+ 7FA133AE16D7309E008204B7 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 7FA133AF16D7309E008204B7 /* Build configuration list for PBXNativeTarget "ISBackGesture" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 7FA133B016D7309E008204B7 /* Debug */,
+ 7FA133B116D7309E008204B7 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 7FB6661116D7316100EF6380 /* Build configuration list for PBXNativeTarget "DemoApp" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 7FB6661216D7316100EF6380 /* Debug */,
+ 7FB6661316D7316100EF6380 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 7FA1339916D7309E008204B7 /* Project object */;
+}
1  ISBackGesture/ISBackGesture.h
@@ -0,0 +1 @@
+#import <ISBackGesture/UIViewController+BackGesture.h>
8 ISBackGesture/UIViewController+BackGesture.h
@@ -0,0 +1,8 @@
+#import <UIKit/UIKit.h>
+
+@interface UIViewController (BackGesture)
+
+@property (nonatomic) BOOL backGestureEnabled;
+@property (nonatomic, readonly) float backProgress;
+
+@end
130 ISBackGesture/UIViewController+BackGesture.m
@@ -0,0 +1,130 @@
+#import "UIViewController+BackGesture.h"
+#import <objc/runtime.h>
+
+static const char *ISBackGestureEnabledKey = "ISBackGestureEnabledKey";
+static const char *ISBackGestureProgressKey = "ISBackGestureProgressKey";
+static const char *ISBackGestureRecognizerKey = "ISBackGestureRecognizerKey";
+
+static void ISSwizzleInstanceMethod(Class c, SEL original, SEL alternative)
+{
+ Method orgMethod = class_getInstanceMethod(c, original);
+ Method altMethod = class_getInstanceMethod(c, alternative);
+
+ if(class_addMethod(c, original, method_getImplementation(altMethod), method_getTypeEncoding(altMethod))) {
+ class_replaceMethod(c, alternative, method_getImplementation(orgMethod), method_getTypeEncoding(orgMethod));
+ } else {
+ method_exchangeImplementations(orgMethod, altMethod);
+ }
+}
+
+@interface UIViewController ()
+
+@property (nonatomic, strong) UIPanGestureRecognizer *backGestureRecognizer;
+
+@end
+
+@implementation UIViewController (BackGesture)
+
+#pragma mark -
+
++ (void)load
+{
+ @autoreleasepool {
+ ISSwizzleInstanceMethod(self, @selector(viewDidLoad), @selector(_viewDidLoad));
+ ISSwizzleInstanceMethod(self, @selector(viewDidUnload), @selector(_viewDidUnload));
+ }
+}
+
+#pragma mark - accessors
+
+- (float)backProgress
+{
+ return [objc_getAssociatedObject(self, ISBackGestureProgressKey) floatValue];
+}
+
+- (void)setBackProgress:(float)backProgress
+{
+ objc_setAssociatedObject(self, ISBackGestureProgressKey, @(backProgress), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+}
+
+- (BOOL)backGestureEnabled
+{
+ return [objc_getAssociatedObject(self, ISBackGestureEnabledKey) boolValue];
+}
+
+- (void)setBackGestureEnabled:(BOOL)backGestureEnabled
+{
+ objc_setAssociatedObject(self, ISBackGestureEnabledKey, @(backGestureEnabled), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+}
+
+- (UIPanGestureRecognizer *)backGestureRecognizer
+{
+ return objc_getAssociatedObject(self, ISBackGestureRecognizerKey);
+}
+
+- (void)setBackGestureRecognizer:(UIPanGestureRecognizer *)backGestureRecognizer
+{
+ objc_setAssociatedObject(self, ISBackGestureRecognizerKey, backGestureRecognizer, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+}
+
+#pragma mark -
+
+- (void)_viewDidLoad
+{
+ [self startRecognizing];
+}
+
+- (void)_viewDidUnload
+{
+ self.backGestureRecognizer = nil;
+}
+
+#pragma mark -
+
+- (void)startRecognizing
+{
+ if (!self.isViewLoaded || !self.backGestureEnabled) {
+ return;
+ }
+
+ self.backGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)];
+ [self.view addGestureRecognizer:self.backGestureRecognizer];
+}
+
+- (void)stopRecognizing
+{
+ if (!self.isViewLoaded || self.backGestureEnabled) {
+ return;
+ }
+
+ [self.view removeGestureRecognizer:self.backGestureRecognizer];
+ self.backGestureRecognizer = nil;
+}
+
+- (void)handleGesture:(UIPanGestureRecognizer *)gestureRecognizer
+{
+ if ([self.navigationController.viewControllers count] < 2) {
+ return;
+ }
+
+ CGPoint translation = [self.backGestureRecognizer translationInView:self.backGestureRecognizer.view];
+ if (self.backGestureRecognizer.state == UIGestureRecognizerStateEnded) {
+ self.backProgress = 0.f;
+ return;
+ }
+
+ CGFloat progress = translation.x / 150.f;
+ if (progress < 0.f) {
+ progress = 0.f;
+ }
+ if (progress > 1.f) {
+ progress = 1.f;
+ }
+ self.backProgress = progress;
+
+ if (self.backProgress >= 1.f) {
+ [self.navigationController popViewControllerAnimated:YES];
+ }
+}
+
+@end
7 Makefile
@@ -0,0 +1,7 @@
+default:
+ if [ -a Products ]; then rm -R Products; fi;
+ mkdir -p Products/ISBackGesture
+ xcodebuild -target ISBackGesture -sdk iphoneos -arch armv7 -arch armv7s clean build
+ xcodebuild -target ISBackGesture -sdk iphonesimulator -arch i386 clean build
+ xcrun lipo -create build/Release-iphonesimulator/libISBackGesture.a build/Release-iphoneos/libISBackGesture.a -output Products/libISBackGesture.a
+ cp ISBackGesture/*.h Products/ISBackGesture/
73 README.md
@@ -0,0 +1,73 @@
+equips `UIViewController` with recognizing "swipe to back".
+
+## Requirements
+
+- OS: iOS4 or later
+- Arch: armv7, armv7s or i386
+
+## Usage
+
+import the header file.
+
+```objectivec
+#import <ISBackGesture/ISBackGesture.h>
+```
+
+to enable recognizing back gesture, set `backGestureEnabled` `YES`.
+
+```objectivec
+UIViewController *viewController = [[UIViewController alloc] init];
+viewController.backGestureEnabled = YES;
+```
+
+to get the progress of backgesture, access `backProgress`.
+```
+float progress = viewController.backProgress;
+```
+
+## Installing
+
+### CocoaPods
+
+If you use CocoaPods, you can install ISBackGesture by inserting config below.
+```
+pod 'ISBackGesture', :git => 'https://github.com/ishkawa/ISBackGesture.git'
+```
+
+### Build from Source Code
+
+#### Clone and Build
+
+- `git clone https://github.com/ishkawa/ISBackGesture.git`
+- `cd ISBackGesture`
+- `make`
+
+
+#### Copy files to your project
+
+copy files under `Products/`
+
+- `libISBackGesture.a`
+- `ISBackGesture` (Header files)
+
+
+#### Add Linker Flag
+
+open .xcodeproj -> Build Settings and add `-ObjC` option into "Other Linker Flags".
+this config is required to load categories in a static library.
+
+#### Add Header Search Path
+
+open .xcodeproj -> Build Settings and add `$(SRCROOT)/` option into "Header Search Path".
+(If you copied ISBackGesture files into `$(SRCROOT)/Library`, add `$(SRCROOT)/Library`.)
+
+## License
+
+Copyright (c) 2013 Yosuke Ishikawa
+
+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.
+
Please sign in to comment.
Something went wrong with that request. Please try again.