├── .gitignore ├── .travis.yml ├── DLPanableWebView.podspec ├── DLPanableWebView ├── DLPanableWebView.h └── DLPanableWebView.m ├── Demo ├── DLPanableWebViewDemo.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── WorkspaceSettings.xcsettings │ └── xcshareddata │ │ └── xcschemes │ │ └── DLPanableWebViewDemo.xcscheme └── DLPanableWebViewDemo │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard │ ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ ├── WebViewController.h │ ├── WebViewController.m │ └── main.m ├── LICENSE ├── README.md └── images └── demo.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | *.DS_Store 20 | 21 | # CocoaPods 22 | # 23 | # We recommend against adding the Pods directory to your .gitignore. However 24 | # you should judge for yourself, the pros and cons are mentioned at: 25 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 26 | # 27 | #Pods/ 28 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | xcode_project: Demo/DLPanableWebViewDemo.xcodeproj # path to your xcodeproj folder 3 | xcode_scheme: DLPanableWebViewDemo 4 | 5 | script: 6 | - xctool -project Demo/DLPanableWebViewDemo.xcodeproj -scheme DLPanableWebViewDemo build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO 7 | -------------------------------------------------------------------------------- /DLPanableWebView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "DLPanableWebView" 4 | s.version = "0.9.1" 5 | s.summary = "Extend UIWebView to support pan left to go back gesture.(like Wechat in-app browser)" 6 | 7 | s.description = <<-DESC 8 | In Safari, besides tap on 'back' and 'forward' button, you can pan left & right to go back and forward. 9 | But UIWebView does not support this gesture. So I extented UIWebView to support the gesture(now only go back gesture). 10 | DESC 11 | 12 | s.homepage = "https://github.com/agdsdl/DLPanableWebView" 13 | s.screenshots = "https://github.com/agdsdl/DLPanableWebView/raw/master/images/demo.gif" 14 | 15 | 16 | s.license = { :type => 'MIT', :file => 'LICENSE' } 17 | 18 | s.author = { "Dongle Su" => "agdsdl@sina.com.cn" } 19 | s.social_media_url = "http://weibo.com/u/1421886475" 20 | 21 | s.platform = :ios, "6.0" 22 | s.ios.deployment_target = "6.0" 23 | 24 | s.source = { :git => "https://github.com/agdsdl/DLPanableWebView.git", :tag => s.version.to_s } 25 | s.source_files = "DLPanableWebView/*.{m,h}" 26 | 27 | s.requires_arc = true 28 | 29 | end 30 | -------------------------------------------------------------------------------- /DLPanableWebView/DLPanableWebView.h: -------------------------------------------------------------------------------- 1 | // 2 | // DLPanableWebView.h 3 | // hybirdDemo 4 | // 5 | // Created by Dongle Su on 15/6/18. 6 | // Copyright (c) 2015年 dongle. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class DLPanableWebView; 12 | 13 | @protocol DLPanableWebViewHandler 14 | @optional 15 | - (void)DLPanableWebView:(DLPanableWebView *)webView panPopGesture:(UIPanGestureRecognizer *)pan; 16 | @end 17 | 18 | @interface DLPanableWebView : UIWebView 19 | @property(nonatomic, weak) IBOutlet id panDelegate; 20 | @property(nonatomic, assign) BOOL enablePanGesture; 21 | @end 22 | -------------------------------------------------------------------------------- /DLPanableWebView/DLPanableWebView.m: -------------------------------------------------------------------------------- 1 | // 2 | // DLPanableWebView.m 3 | // hybirdDemo 4 | // 5 | // Created by Dongle Su on 15/6/18. 6 | // Copyright (c) 2015年 dongle. All rights reserved. 7 | // 8 | 9 | #import "DLPanableWebView.h" 10 | @interface DLPanableWebView() 11 | @end 12 | 13 | @implementation DLPanableWebView{ 14 | UIGestureRecognizer* popGesture_; 15 | CGFloat panStartX_; 16 | 17 | NSMutableArray *historyStack_; 18 | UIImageView *_historyView; 19 | 20 | __weak id originDelegate_; 21 | } 22 | 23 | + (UIImage *)screenshotOfView:(UIView *)view{ 24 | UIGraphicsBeginImageContextWithOptions(view.frame.size, YES, 0.0); 25 | 26 | if ([view respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)]) { 27 | [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES]; 28 | } 29 | else{ 30 | [view.layer renderInContext:UIGraphicsGetCurrentContext()]; 31 | } 32 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 33 | UIGraphicsEndImageContext(); 34 | return image; 35 | } 36 | 37 | + (void)addShadowToView:(UIView *)view{ 38 | CALayer *layer = view.layer; 39 | UIBezierPath *path = [UIBezierPath bezierPathWithRect:layer.bounds]; 40 | layer.shadowPath = path.CGPath; 41 | layer.shadowColor = [UIColor blackColor].CGColor; 42 | layer.shadowOffset = CGSizeZero; 43 | layer.shadowOpacity = 0.4f; 44 | layer.shadowRadius = 8.0f; 45 | } 46 | 47 | - (void)setDelegate:(id)delegate{ 48 | originDelegate_ = delegate; 49 | } 50 | 51 | - (id)delegate{ 52 | return originDelegate_; 53 | } 54 | 55 | - (void)goBack{ 56 | [super goBack]; 57 | 58 | [historyStack_ removeLastObject]; 59 | } 60 | 61 | - (void)setEnablePanGesture:(BOOL)enablePanGesture{ 62 | popGesture_.enabled = enablePanGesture; 63 | } 64 | 65 | - (BOOL)enablePanGesture{ 66 | return popGesture_.enabled; 67 | } 68 | 69 | - (UIImageView *)historyView{ 70 | if (!_historyView) { 71 | if (self.superview) { 72 | _historyView = [[UIImageView alloc] initWithFrame:self.bounds]; 73 | [self.superview insertSubview:_historyView belowSubview:self]; 74 | } 75 | } 76 | 77 | return _historyView; 78 | } 79 | - (id)init{ 80 | if (self = [super init]) { 81 | [self commonInit]; 82 | } 83 | return self; 84 | } 85 | 86 | - (id)initWithCoder:(NSCoder *)aDecoder{ 87 | if (self = [super initWithCoder:aDecoder]) { 88 | [self commonInit]; 89 | } 90 | return self; 91 | } 92 | 93 | - (id)initWithFrame:(CGRect)frame{ 94 | if (self = [super initWithFrame:frame]) { 95 | [self commonInit]; 96 | } 97 | return self; 98 | } 99 | 100 | - (void)commonInit{ 101 | historyStack_ = [NSMutableArray array]; 102 | 103 | popGesture_ = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGesture:)]; 104 | [self addGestureRecognizer:popGesture_]; 105 | 106 | [super setDelegate:self]; 107 | 108 | [DLPanableWebView addShadowToView:self]; 109 | } 110 | 111 | - (void)dealloc{ 112 | //NSLog(@"DLPanableWebView dealloc"); 113 | if (_historyView) { 114 | [_historyView removeFromSuperview]; 115 | _historyView = nil; 116 | } 117 | } 118 | 119 | - (void)layoutSubviews{ 120 | [super layoutSubviews]; 121 | [self historyView].frame = self.bounds; 122 | } 123 | 124 | #pragma mark === gesture=== 125 | - (void)panGesture:(UIPanGestureRecognizer *)sender{ 126 | if (![self canGoBack] || historyStack_.count == 0) { 127 | if (self.panDelegate && [self.panDelegate respondsToSelector:@selector(DLPanableWebView:panPopGesture:)]) { 128 | [self.panDelegate DLPanableWebView:self panPopGesture:sender]; 129 | } 130 | 131 | return; 132 | } 133 | 134 | CGPoint point = [sender translationInView:self]; 135 | if (sender.state == UIGestureRecognizerStateBegan) { 136 | panStartX_ = point.x; 137 | } 138 | else if (sender.state == UIGestureRecognizerStateChanged){ 139 | CGFloat deltaX = point.x - panStartX_; 140 | if (deltaX > 0) { 141 | if ([self canGoBack]) { 142 | assert([historyStack_ count] > 0); 143 | 144 | CGRect rc = self.frame; 145 | rc.origin.x = deltaX; 146 | self.frame = rc; 147 | [self historyView].image = [[historyStack_ lastObject] objectForKey:@"preview"]; 148 | rc.origin.x = -self.bounds.size.width/2.0f + deltaX/2.0f; 149 | [self historyView].frame = rc; 150 | } 151 | } 152 | } 153 | else if (sender.state == UIGestureRecognizerStateEnded){ 154 | CGFloat deltaX = point.x - panStartX_; 155 | CGFloat duration = .5f; 156 | if ([self canGoBack]) { 157 | if (deltaX > self.bounds.size.width/4.0f) { 158 | [UIView animateWithDuration:(1.0f - deltaX/self.bounds.size.width)*duration animations:^{ 159 | CGRect rc = self.frame; 160 | rc.origin.x = self.bounds.size.width; 161 | self.frame = rc; 162 | rc.origin.x = 0; 163 | [self historyView].frame = rc; 164 | } completion:^(BOOL finished) { 165 | CGRect rc = self.frame; 166 | rc.origin.x = 0; 167 | self.frame = rc; 168 | [self goBack]; 169 | 170 | [self historyView].image = nil; 171 | }]; 172 | } 173 | else{ 174 | [UIView animateWithDuration:(deltaX/self.bounds.size.width)*duration animations:^{ 175 | CGRect rc = self.frame; 176 | rc.origin.x = 0; 177 | self.frame = rc; 178 | rc.origin.x = -self.bounds.size.width/2.0f; 179 | [self historyView].frame = rc; 180 | } completion:^(BOOL finished) { 181 | 182 | }]; 183 | } 184 | } 185 | } 186 | } 187 | 188 | #pragma mark ===uiwebview=== 189 | - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{ 190 | BOOL ret = YES; 191 | 192 | if (originDelegate_ && [originDelegate_ respondsToSelector:@selector(webView:shouldStartLoadWithRequest:navigationType:)]) { 193 | ret = [originDelegate_ webView:webView shouldStartLoadWithRequest:request navigationType:navigationType]; 194 | } 195 | 196 | BOOL isFragmentJump = NO; 197 | if (request.URL.fragment) { 198 | NSString *nonFragmentURL = [request.URL.absoluteString stringByReplacingOccurrencesOfString:[@"#" stringByAppendingString:request.URL.fragment] withString:@""]; 199 | if (webView.request.URL.absoluteString) { 200 | NSString *preNonFragmentURL; 201 | if (webView.request.URL.fragment) { 202 | preNonFragmentURL = [webView.request.URL.absoluteString stringByReplacingOccurrencesOfString:[@"#" stringByAppendingString:webView.request.URL.fragment] withString:@""]; 203 | } 204 | else{ 205 | preNonFragmentURL = webView.request.URL.absoluteString; 206 | } 207 | isFragmentJump = [nonFragmentURL isEqualToString:preNonFragmentURL]; 208 | } 209 | } 210 | 211 | BOOL isTopLevelNavigation = [request.mainDocumentURL isEqual:request.URL]; 212 | 213 | BOOL isHTTPOrFile = [request.URL.scheme isEqualToString:@"http"] || [request.URL.scheme isEqualToString:@"https"] || [request.URL.scheme isEqualToString:@"file"]; 214 | if (ret && !isFragmentJump && isHTTPOrFile && isTopLevelNavigation) { 215 | if ((navigationType == UIWebViewNavigationTypeLinkClicked || navigationType == UIWebViewNavigationTypeOther) && [[webView.request.URL description] length]) { 216 | if (![[[historyStack_ lastObject] objectForKey:@"url"] isEqualToString:[self.request.URL description]]) { 217 | UIImage *curPreview = [DLPanableWebView screenshotOfView:self]; 218 | [historyStack_ addObject:@{@"preview":curPreview, @"url":[self.request.URL description]}]; 219 | } 220 | } 221 | } 222 | return ret; 223 | } 224 | 225 | - (void)webViewDidStartLoad:(UIWebView *)webView{ 226 | //[UIApplication sharedApplication].networkActivityIndicatorVisible = YES; 227 | if (originDelegate_ && [originDelegate_ respondsToSelector:@selector(webViewDidStartLoad:)]) { 228 | [originDelegate_ webViewDidStartLoad:webView]; 229 | } 230 | } 231 | - (void)webViewDidFinishLoad:(UIWebView *)webView { 232 | //[UIApplication sharedApplication].networkActivityIndicatorVisible = NO; 233 | if (originDelegate_ && [originDelegate_ respondsToSelector:@selector(webViewDidFinishLoad:)]) { 234 | [originDelegate_ webViewDidFinishLoad:webView]; 235 | } 236 | } 237 | 238 | - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{ 239 | //[UIApplication sharedApplication].networkActivityIndicatorVisible = NO; 240 | if (originDelegate_ && [originDelegate_ respondsToSelector:@selector(webView:didFailLoadWithError:)]) { 241 | [originDelegate_ webView:webView didFailLoadWithError:error]; 242 | } 243 | } 244 | 245 | @end 246 | -------------------------------------------------------------------------------- /Demo/DLPanableWebViewDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 4D39FD631B419F5000D1EC80 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D39FD621B419F5000D1EC80 /* main.m */; }; 11 | 4D39FD661B419F5000D1EC80 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D39FD651B419F5000D1EC80 /* AppDelegate.m */; }; 12 | 4D39FD691B419F5000D1EC80 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D39FD681B419F5000D1EC80 /* ViewController.m */; }; 13 | 4D39FD6C1B419F5000D1EC80 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4D39FD6A1B419F5000D1EC80 /* Main.storyboard */; }; 14 | 4D39FD6E1B419F5000D1EC80 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4D39FD6D1B419F5000D1EC80 /* Images.xcassets */; }; 15 | 4D39FD711B419F5000D1EC80 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4D39FD6F1B419F5000D1EC80 /* LaunchScreen.xib */; }; 16 | 4D39FD891B41A0CC00D1EC80 /* DLPanableWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D39FD881B41A0CC00D1EC80 /* DLPanableWebView.m */; }; 17 | 4D39FD8C1B41A12F00D1EC80 /* WebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D39FD8B1B41A12F00D1EC80 /* WebViewController.m */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXFileReference section */ 21 | 4D39FD5D1B419F5000D1EC80 /* DLPanableWebViewDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DLPanableWebViewDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 22 | 4D39FD611B419F5000D1EC80 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 23 | 4D39FD621B419F5000D1EC80 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 24 | 4D39FD641B419F5000D1EC80 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 25 | 4D39FD651B419F5000D1EC80 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 26 | 4D39FD671B419F5000D1EC80 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 27 | 4D39FD681B419F5000D1EC80 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 28 | 4D39FD6B1B419F5000D1EC80 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 29 | 4D39FD6D1B419F5000D1EC80 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 30 | 4D39FD701B419F5000D1EC80 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 31 | 4D39FD871B41A0CC00D1EC80 /* DLPanableWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DLPanableWebView.h; sourceTree = ""; }; 32 | 4D39FD881B41A0CC00D1EC80 /* DLPanableWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DLPanableWebView.m; sourceTree = ""; }; 33 | 4D39FD8A1B41A12F00D1EC80 /* WebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewController.h; sourceTree = ""; }; 34 | 4D39FD8B1B41A12F00D1EC80 /* WebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewController.m; sourceTree = ""; }; 35 | /* End PBXFileReference section */ 36 | 37 | /* Begin PBXFrameworksBuildPhase section */ 38 | 4D39FD5A1B419F5000D1EC80 /* Frameworks */ = { 39 | isa = PBXFrameworksBuildPhase; 40 | buildActionMask = 2147483647; 41 | files = ( 42 | ); 43 | runOnlyForDeploymentPostprocessing = 0; 44 | }; 45 | /* End PBXFrameworksBuildPhase section */ 46 | 47 | /* Begin PBXGroup section */ 48 | 4D39FD541B419F5000D1EC80 = { 49 | isa = PBXGroup; 50 | children = ( 51 | 4D39FD5F1B419F5000D1EC80 /* DLPanableWebViewDemo */, 52 | 4D39FD5E1B419F5000D1EC80 /* Products */, 53 | ); 54 | sourceTree = ""; 55 | }; 56 | 4D39FD5E1B419F5000D1EC80 /* Products */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | 4D39FD5D1B419F5000D1EC80 /* DLPanableWebViewDemo.app */, 60 | ); 61 | name = Products; 62 | sourceTree = ""; 63 | }; 64 | 4D39FD5F1B419F5000D1EC80 /* DLPanableWebViewDemo */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 4D39FD861B41A0CC00D1EC80 /* DLPanableWebView */, 68 | 4D39FD641B419F5000D1EC80 /* AppDelegate.h */, 69 | 4D39FD651B419F5000D1EC80 /* AppDelegate.m */, 70 | 4D39FD671B419F5000D1EC80 /* ViewController.h */, 71 | 4D39FD681B419F5000D1EC80 /* ViewController.m */, 72 | 4D39FD8A1B41A12F00D1EC80 /* WebViewController.h */, 73 | 4D39FD8B1B41A12F00D1EC80 /* WebViewController.m */, 74 | 4D39FD6A1B419F5000D1EC80 /* Main.storyboard */, 75 | 4D39FD6D1B419F5000D1EC80 /* Images.xcassets */, 76 | 4D39FD6F1B419F5000D1EC80 /* LaunchScreen.xib */, 77 | 4D39FD601B419F5000D1EC80 /* Supporting Files */, 78 | ); 79 | path = DLPanableWebViewDemo; 80 | sourceTree = ""; 81 | }; 82 | 4D39FD601B419F5000D1EC80 /* Supporting Files */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | 4D39FD611B419F5000D1EC80 /* Info.plist */, 86 | 4D39FD621B419F5000D1EC80 /* main.m */, 87 | ); 88 | name = "Supporting Files"; 89 | sourceTree = ""; 90 | }; 91 | 4D39FD861B41A0CC00D1EC80 /* DLPanableWebView */ = { 92 | isa = PBXGroup; 93 | children = ( 94 | 4D39FD871B41A0CC00D1EC80 /* DLPanableWebView.h */, 95 | 4D39FD881B41A0CC00D1EC80 /* DLPanableWebView.m */, 96 | ); 97 | name = DLPanableWebView; 98 | path = ../../DLPanableWebView; 99 | sourceTree = ""; 100 | }; 101 | /* End PBXGroup section */ 102 | 103 | /* Begin PBXNativeTarget section */ 104 | 4D39FD5C1B419F5000D1EC80 /* DLPanableWebViewDemo */ = { 105 | isa = PBXNativeTarget; 106 | buildConfigurationList = 4D39FD801B419F5100D1EC80 /* Build configuration list for PBXNativeTarget "DLPanableWebViewDemo" */; 107 | buildPhases = ( 108 | 4D39FD591B419F5000D1EC80 /* Sources */, 109 | 4D39FD5A1B419F5000D1EC80 /* Frameworks */, 110 | 4D39FD5B1B419F5000D1EC80 /* Resources */, 111 | ); 112 | buildRules = ( 113 | ); 114 | dependencies = ( 115 | ); 116 | name = DLPanableWebViewDemo; 117 | productName = DLPanableWebViewDemo; 118 | productReference = 4D39FD5D1B419F5000D1EC80 /* DLPanableWebViewDemo.app */; 119 | productType = "com.apple.product-type.application"; 120 | }; 121 | /* End PBXNativeTarget section */ 122 | 123 | /* Begin PBXProject section */ 124 | 4D39FD551B419F5000D1EC80 /* Project object */ = { 125 | isa = PBXProject; 126 | attributes = { 127 | LastUpgradeCheck = 0630; 128 | ORGANIZATIONNAME = dongle; 129 | TargetAttributes = { 130 | 4D39FD5C1B419F5000D1EC80 = { 131 | CreatedOnToolsVersion = 6.3.2; 132 | }; 133 | }; 134 | }; 135 | buildConfigurationList = 4D39FD581B419F5000D1EC80 /* Build configuration list for PBXProject "DLPanableWebViewDemo" */; 136 | compatibilityVersion = "Xcode 3.2"; 137 | developmentRegion = English; 138 | hasScannedForEncodings = 0; 139 | knownRegions = ( 140 | en, 141 | Base, 142 | ); 143 | mainGroup = 4D39FD541B419F5000D1EC80; 144 | productRefGroup = 4D39FD5E1B419F5000D1EC80 /* Products */; 145 | projectDirPath = ""; 146 | projectRoot = ""; 147 | targets = ( 148 | 4D39FD5C1B419F5000D1EC80 /* DLPanableWebViewDemo */, 149 | ); 150 | }; 151 | /* End PBXProject section */ 152 | 153 | /* Begin PBXResourcesBuildPhase section */ 154 | 4D39FD5B1B419F5000D1EC80 /* Resources */ = { 155 | isa = PBXResourcesBuildPhase; 156 | buildActionMask = 2147483647; 157 | files = ( 158 | 4D39FD6C1B419F5000D1EC80 /* Main.storyboard in Resources */, 159 | 4D39FD711B419F5000D1EC80 /* LaunchScreen.xib in Resources */, 160 | 4D39FD6E1B419F5000D1EC80 /* Images.xcassets in Resources */, 161 | ); 162 | runOnlyForDeploymentPostprocessing = 0; 163 | }; 164 | /* End PBXResourcesBuildPhase section */ 165 | 166 | /* Begin PBXSourcesBuildPhase section */ 167 | 4D39FD591B419F5000D1EC80 /* Sources */ = { 168 | isa = PBXSourcesBuildPhase; 169 | buildActionMask = 2147483647; 170 | files = ( 171 | 4D39FD691B419F5000D1EC80 /* ViewController.m in Sources */, 172 | 4D39FD8C1B41A12F00D1EC80 /* WebViewController.m in Sources */, 173 | 4D39FD891B41A0CC00D1EC80 /* DLPanableWebView.m in Sources */, 174 | 4D39FD661B419F5000D1EC80 /* AppDelegate.m in Sources */, 175 | 4D39FD631B419F5000D1EC80 /* main.m in Sources */, 176 | ); 177 | runOnlyForDeploymentPostprocessing = 0; 178 | }; 179 | /* End PBXSourcesBuildPhase section */ 180 | 181 | /* Begin PBXVariantGroup section */ 182 | 4D39FD6A1B419F5000D1EC80 /* Main.storyboard */ = { 183 | isa = PBXVariantGroup; 184 | children = ( 185 | 4D39FD6B1B419F5000D1EC80 /* Base */, 186 | ); 187 | name = Main.storyboard; 188 | sourceTree = ""; 189 | }; 190 | 4D39FD6F1B419F5000D1EC80 /* LaunchScreen.xib */ = { 191 | isa = PBXVariantGroup; 192 | children = ( 193 | 4D39FD701B419F5000D1EC80 /* Base */, 194 | ); 195 | name = LaunchScreen.xib; 196 | sourceTree = ""; 197 | }; 198 | /* End PBXVariantGroup section */ 199 | 200 | /* Begin XCBuildConfiguration section */ 201 | 4D39FD7E1B419F5100D1EC80 /* Debug */ = { 202 | isa = XCBuildConfiguration; 203 | buildSettings = { 204 | ALWAYS_SEARCH_USER_PATHS = NO; 205 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 206 | CLANG_CXX_LIBRARY = "libc++"; 207 | CLANG_ENABLE_MODULES = YES; 208 | CLANG_ENABLE_OBJC_ARC = YES; 209 | CLANG_WARN_BOOL_CONVERSION = YES; 210 | CLANG_WARN_CONSTANT_CONVERSION = YES; 211 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 212 | CLANG_WARN_EMPTY_BODY = YES; 213 | CLANG_WARN_ENUM_CONVERSION = YES; 214 | CLANG_WARN_INT_CONVERSION = YES; 215 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 216 | CLANG_WARN_UNREACHABLE_CODE = YES; 217 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 218 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 219 | COPY_PHASE_STRIP = NO; 220 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 221 | ENABLE_STRICT_OBJC_MSGSEND = YES; 222 | GCC_C_LANGUAGE_STANDARD = gnu99; 223 | GCC_DYNAMIC_NO_PIC = NO; 224 | GCC_NO_COMMON_BLOCKS = YES; 225 | GCC_OPTIMIZATION_LEVEL = 0; 226 | GCC_PREPROCESSOR_DEFINITIONS = ( 227 | "DEBUG=1", 228 | "$(inherited)", 229 | ); 230 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 231 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 232 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 233 | GCC_WARN_UNDECLARED_SELECTOR = YES; 234 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 235 | GCC_WARN_UNUSED_FUNCTION = YES; 236 | GCC_WARN_UNUSED_VARIABLE = YES; 237 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 238 | MTL_ENABLE_DEBUG_INFO = YES; 239 | ONLY_ACTIVE_ARCH = YES; 240 | SDKROOT = iphoneos; 241 | }; 242 | name = Debug; 243 | }; 244 | 4D39FD7F1B419F5100D1EC80 /* Release */ = { 245 | isa = XCBuildConfiguration; 246 | buildSettings = { 247 | ALWAYS_SEARCH_USER_PATHS = NO; 248 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 249 | CLANG_CXX_LIBRARY = "libc++"; 250 | CLANG_ENABLE_MODULES = YES; 251 | CLANG_ENABLE_OBJC_ARC = YES; 252 | CLANG_WARN_BOOL_CONVERSION = YES; 253 | CLANG_WARN_CONSTANT_CONVERSION = YES; 254 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 255 | CLANG_WARN_EMPTY_BODY = YES; 256 | CLANG_WARN_ENUM_CONVERSION = YES; 257 | CLANG_WARN_INT_CONVERSION = YES; 258 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 259 | CLANG_WARN_UNREACHABLE_CODE = YES; 260 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 261 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 262 | COPY_PHASE_STRIP = NO; 263 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 264 | ENABLE_NS_ASSERTIONS = NO; 265 | ENABLE_STRICT_OBJC_MSGSEND = YES; 266 | GCC_C_LANGUAGE_STANDARD = gnu99; 267 | GCC_NO_COMMON_BLOCKS = YES; 268 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 269 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 270 | GCC_WARN_UNDECLARED_SELECTOR = YES; 271 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 272 | GCC_WARN_UNUSED_FUNCTION = YES; 273 | GCC_WARN_UNUSED_VARIABLE = YES; 274 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 275 | MTL_ENABLE_DEBUG_INFO = NO; 276 | SDKROOT = iphoneos; 277 | VALIDATE_PRODUCT = YES; 278 | }; 279 | name = Release; 280 | }; 281 | 4D39FD811B419F5100D1EC80 /* Debug */ = { 282 | isa = XCBuildConfiguration; 283 | buildSettings = { 284 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 285 | INFOPLIST_FILE = DLPanableWebViewDemo/Info.plist; 286 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 287 | PRODUCT_NAME = "$(TARGET_NAME)"; 288 | TARGETED_DEVICE_FAMILY = "1,2"; 289 | }; 290 | name = Debug; 291 | }; 292 | 4D39FD821B419F5100D1EC80 /* Release */ = { 293 | isa = XCBuildConfiguration; 294 | buildSettings = { 295 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 296 | INFOPLIST_FILE = DLPanableWebViewDemo/Info.plist; 297 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 298 | PRODUCT_NAME = "$(TARGET_NAME)"; 299 | TARGETED_DEVICE_FAMILY = "1,2"; 300 | }; 301 | name = Release; 302 | }; 303 | /* End XCBuildConfiguration section */ 304 | 305 | /* Begin XCConfigurationList section */ 306 | 4D39FD581B419F5000D1EC80 /* Build configuration list for PBXProject "DLPanableWebViewDemo" */ = { 307 | isa = XCConfigurationList; 308 | buildConfigurations = ( 309 | 4D39FD7E1B419F5100D1EC80 /* Debug */, 310 | 4D39FD7F1B419F5100D1EC80 /* Release */, 311 | ); 312 | defaultConfigurationIsVisible = 0; 313 | defaultConfigurationName = Release; 314 | }; 315 | 4D39FD801B419F5100D1EC80 /* Build configuration list for PBXNativeTarget "DLPanableWebViewDemo" */ = { 316 | isa = XCConfigurationList; 317 | buildConfigurations = ( 318 | 4D39FD811B419F5100D1EC80 /* Debug */, 319 | 4D39FD821B419F5100D1EC80 /* Release */, 320 | ); 321 | defaultConfigurationIsVisible = 0; 322 | defaultConfigurationName = Release; 323 | }; 324 | /* End XCConfigurationList section */ 325 | }; 326 | rootObject = 4D39FD551B419F5000D1EC80 /* Project object */; 327 | } 328 | -------------------------------------------------------------------------------- /Demo/DLPanableWebViewDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Demo/DLPanableWebViewDemo.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Demo/DLPanableWebViewDemo.xcodeproj/xcshareddata/xcschemes/DLPanableWebViewDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Demo/DLPanableWebViewDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // DLPanableWebViewDemo 4 | // 5 | // Created by 苏东乐 on 15/6/29. 6 | // Copyright (c) 2015年 dongle. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /Demo/DLPanableWebViewDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // DLPanableWebViewDemo 4 | // 5 | // Created by 苏东乐 on 15/6/29. 6 | // Copyright (c) 2015年 dongle. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // 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. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // 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. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Demo/DLPanableWebViewDemo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Demo/DLPanableWebViewDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /Demo/DLPanableWebViewDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Demo/DLPanableWebViewDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.dongle.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSAppTransportSecurity 26 | 27 | NSAllowsArbitraryLoads 28 | 29 | 30 | UILaunchStoryboardName 31 | LaunchScreen 32 | UIMainStoryboardFile 33 | Main 34 | UIRequiredDeviceCapabilities 35 | 36 | armv7 37 | 38 | UISupportedInterfaceOrientations 39 | 40 | UIInterfaceOrientationPortrait 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Demo/DLPanableWebViewDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // DLPanableWebViewDemo 4 | // 5 | // Created by 苏东乐 on 15/6/29. 6 | // Copyright (c) 2015年 dongle. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Demo/DLPanableWebViewDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // DLPanableWebViewDemo 4 | // 5 | // Created by 苏东乐 on 15/6/29. 6 | // Copyright (c) 2015年 dongle. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "WebViewController.h" 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view, typically from a nib. 21 | } 22 | 23 | - (void)didReceiveMemoryWarning { 24 | [super didReceiveMemoryWarning]; 25 | // Dispose of any resources that can be recreated. 26 | } 27 | 28 | 29 | #pragma mark - Navigation 30 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 31 | if ([segue.identifier isEqualToString:@"showWebViewController"]) { 32 | WebViewController *ctrl = [segue destinationViewController]; 33 | ctrl.urlString = @"http://www.baidu.com"; 34 | } 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Demo/DLPanableWebViewDemo/WebViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // WebViewController.h 3 | // DLPanableWebViewDemo 4 | // 5 | // Created by 苏东乐 on 15/6/29. 6 | // Copyright (c) 2015年 dongle. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WebViewController : UIViewController 12 | @property(nonatomic, strong) NSString *urlString; 13 | @end 14 | -------------------------------------------------------------------------------- /Demo/DLPanableWebViewDemo/WebViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // WebViewController.m 3 | // DLPanableWebViewDemo 4 | // 5 | // Created by 苏东乐 on 15/6/29. 6 | // Copyright (c) 2015年 dongle. All rights reserved. 7 | // 8 | 9 | #import "WebViewController.h" 10 | 11 | #import "DLPanableWebView.h" 12 | 13 | #define IS_IPHONE_6_PLUS [UIScreen mainScreen].scale == 3 14 | #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) 15 | 16 | 17 | @interface WebViewController () 18 | @property (weak, nonatomic) IBOutlet DLPanableWebView *webView; 19 | @end 20 | 21 | @implementation WebViewController{ 22 | id navPanTarget_; 23 | SEL navPanAction_; 24 | } 25 | 26 | - (void)viewDidLoad { 27 | [super viewDidLoad]; 28 | 29 | // 获取系统默认手势Handler并保存 30 | if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) { 31 | NSMutableArray *gestureTargets = [self.navigationController.interactivePopGestureRecognizer valueForKey:@"_targets"]; 32 | id gestureTarget = [gestureTargets firstObject]; 33 | navPanTarget_ = [gestureTarget valueForKey:@"_target"]; 34 | navPanAction_ = NSSelectorFromString(@"handleNavigationTransition:"); 35 | } 36 | 37 | 38 | [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.urlString]]]; 39 | } 40 | - (void)dealloc{ 41 | NSLog(@"WebViewController dealloc"); 42 | } 43 | - (void)didReceiveMemoryWarning { 44 | [super didReceiveMemoryWarning]; 45 | // Dispose of any resources that can be recreated. 46 | } 47 | 48 | - (void)DLPanableWebView:(DLPanableWebView *)webView panPopGesture:(UIPanGestureRecognizer *)pan{ 49 | if (navPanTarget_ && [navPanTarget_ respondsToSelector:navPanAction_]) { 50 | [navPanTarget_ performSelector:navPanAction_ withObject:pan]; 51 | } 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /Demo/DLPanableWebViewDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // DLPanableWebViewDemo 4 | // 5 | // Created by 苏东乐 on 15/6/29. 6 | // Copyright (c) 2015年 dongle. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 agdsdl 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DLPanableWebView 2 | [![Build Status](https://travis-ci.org/agdsdl/DLPanableWebView.svg?branch=master)](https://travis-ci.org/agdsdl/DLPanableWebView) 3 | 4 | Extend UIWebView to support pan left to go back gesture(like Wechat in-app browser). 5 | 6 | In Safari, besides tap on 'back' and 'forward' button, you can pan left & right to go back and forward. 7 | 8 | But UIWebView does not support this gesture. So I extented UIWebView to support the gesture(now only go back gesture). 9 | 10 | 扩展了UIWebView,使其支持滑动手势返回(类似微信的In-App浏览器)。 11 | 12 | Safari里面除了点击‘前进’,‘后退’按钮,还可以通过滑动手势来前进和后退。 13 | 14 | 可惜UIWebView不支持这个手势,所以我扩展了UIWebView使其支持滑动手势返回。 15 | 16 | # Screenshot 17 | ![DLPanableWebView](images/demo.gif) 18 | 19 | # Requirements 20 | * IOS6.1 or later 21 | * ARC 22 | 23 | # Setup 24 | * Add 'DLPanableWebView' to your project. 25 | * If you are using CocoaPods: 26 | 27 | Add ```pod 'DLPanableWebView'``` to your [Podfile](http://cocoapods.org/) 28 | 29 | Run ```pod install``` 30 | * else 31 | 32 | Run ```git clone https://github.com/agdsdl/DLPanableWebView.git``` to download our code. 33 | 34 | Add 'DLPanableWebView.h' and 'DLPanableWebView.m' to your project. 35 | * Add #import 36 | ```objc 37 | #import "DLPanableWebView.h" 38 | ``` 39 | * Replace your 'UIWebView' to 'DLPanableWebView'. 40 | ```objc 41 | @interface WebViewController () 42 | @property (weak, nonatomic) IBOutlet DLPanableWebView *webView; 43 | @end 44 | ``` 45 | * That's it! 46 | 47 | Your web view now support pan back gesture. 48 | 49 | # Delegate 50 | [Optional] 51 | 52 | When navigate to the root page, and can not go back any more, ```DLPanableWebView``` will pass pan gesture to ```DLPanableWebViewHandler```. 53 | 54 | You can implement the ```DLPanableWebViewHandler``` protocol and handle the pan gesture if you want. 55 | For example, you can pop your WebViewController if you detect an pan back gesture(Check the demo). 56 | 57 | 58 | # License 59 | -------------------- 60 | The MIT License (MIT) 61 | -------------------------------------------------------------------------------- /images/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agdsdl/DLPanableWebView/4722c741fcf972c20679a4b915320837d4f8fff7/images/demo.gif --------------------------------------------------------------------------------