Have tried many suggestions from this and other forums, including setting "DisallowOverscroll" to "true". Is this broken in phonegap 3.0 by any chance ?
5 Answers
Make certain changes in config.xml
,
If you are using it for Android, then use
<preference name="disallowOverscroll" value="true" />
<preference name="webviewbounce" value="false" />
And for IOS, use like
<preference name="DisallowOverscroll" value="true" />
<preference name="webviewbounce" value="false" />
Hope this helps you.
EDIT
Do a cordova build
after you have made changes in the config.xml
file so that the changes affect to your project. The above steps would solve your problem only after you do a cordova build
-
Thanks - when I create a fresh project this works - both for 2.9.0 and 3.0.0 - so must be some code I modified ;(... !– rysvSep 14, 2013 at 18:15
-
1
-
1I shall add it as an edit to the answer, but @RoryStandley and anyone else who is having the problem even after following this answer, you need to do a
cordova build
after you do this for the changes to take effect on the project. Dec 31, 2014 at 4:48 -
1webviewbounce was superseded by DisallowOverscroll. As of Cordova 3.6.3, it does not apply to Windows Phone.– andreszsFeb 1, 2015 at 16:53
-
In the file AppDelegate.h, after initialized the MainViewController, you could disable this bouncing by set the scrollView class inside the webview by :
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
....................
self.viewController.webView.scrollView.bounces = NO;
return YES;
}
The configuration value in the file config.xml was not used, I searched all in Cordova project.
this is method i've used in xcode way. i dont know how to solve that issue in phonegap maybe this few codes give you idea
in viewdidload:
webView.scrollView.delegate = self;
[webView.scrollView setShowsHorizontalScrollIndicator:NO];
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (scrollView.contentOffset.x > 0 || scrollView.contentOffset.x < 0 )
scrollView.contentOffset = CGPointMake(scrollView.contentOffset.y, 0);
}
For Cordova 3.x and above I believe you can set up your (void)webViewDidFinishLoad
in MainViewController.m
as follows :
- (void)webViewDidFinishLoad:(UIWebView*)theWebView {
// Black base color for background matches the native apps
theWebView.backgroundColor = [UIColor blackColor];
theWebView.scrollView.bounces = NO;
return [super webViewDidFinishLoad:theWebView];
}
Tested: Cordova 3.4, 3.5.
In your AppDelegate.m file , the "(UIApplication*)application didFinishLaunchingWithOptions.." section should look like this:
/**
* This is main kick off after the app inits, the views and Settings are setup here. (preferred - iOS4 and up)
*/
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
CGRect screenBounds = [[UIScreen mainScreen] bounds];
#if __has_feature(objc_arc)
self.window = [[UIWindow alloc] initWithFrame:screenBounds];
#else
self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease];
#endif
self.window.autoresizesSubviews = YES;
#if __has_feature(objc_arc)
self.viewController = [[MainViewController alloc] init];
#else
self.viewController = [[[MainViewController alloc] init] autorelease];
#endif
// Set your app's start page by setting the <content src='foo.html' /> tag in config.xml.
// If necessary, uncomment the line below to override it.
// self.viewController.startPage = @"index.html";
// NOTE: To customize the view's frame size (which defaults to full screen), override
// [self.viewController viewWillAppear:] in your view controller.
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
self.viewController.webView.scrollView.bounces = NO;
return YES;
}
Just add self.viewController.webView.scrollView.bounces = NO; before the return YES;