From f75b30857b18a86f229c9d4baaf2f16afd028c7b Mon Sep 17 00:00:00 2001 From: ivan baktsheev Date: Sun, 10 Nov 2013 22:58:18 +0300 Subject: [PATCH] CB-5594 Add disallowoverscroll option. Similar to the main cordova webview --- src/ios/CDVInAppBrowser.h | 1 + src/ios/CDVInAppBrowser.m | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/ios/CDVInAppBrowser.h b/src/ios/CDVInAppBrowser.h index 885d522..581bcd0 100644 --- a/src/ios/CDVInAppBrowser.h +++ b/src/ios/CDVInAppBrowser.h @@ -54,6 +54,7 @@ @property (nonatomic, assign) BOOL keyboarddisplayrequiresuseraction; @property (nonatomic, assign) BOOL suppressesincrementalrendering; @property (nonatomic, assign) BOOL hidden; +@property (nonatomic, assign) BOOL disallowoverscroll; + (CDVInAppBrowserOptions*)parseOptions:(NSString*)options; diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m index 8b8f46b..60d2fb4 100644 --- a/src/ios/CDVInAppBrowser.m +++ b/src/ios/CDVInAppBrowser.m @@ -149,6 +149,18 @@ } self.inAppBrowserViewController.modalTransitionStyle = transitionStyle; + // prevent webView from bouncing + if (browserOptions.disallowoverscroll) { + if ([self.inAppBrowserViewController.webView respondsToSelector:@selector(scrollView)]) { + ((UIScrollView*)[self.inAppBrowserViewController.webView scrollView]).bounces = NO; + } else { + for (id subview in self.inAppBrowserViewController.webView.subviews) { + if ([[subview class] isSubclassOfClass:[UIScrollView class]]) { + ((UIScrollView*)subview).bounces = NO; + } + } + } + } // UIWebView options self.inAppBrowserViewController.webView.scalesPageToFit = browserOptions.enableviewportscale; @@ -852,6 +864,7 @@ self.keyboarddisplayrequiresuseraction = YES; self.suppressesincrementalrendering = NO; self.hidden = NO; + self.disallowoverscroll = NO; } return self;