UIWebView Bounce

  • 5
  • Idea
  • Updated 7 years ago
  • Implemented
Something that completely destroys the look and feel of native apps is when you drag the app and it bounces. Total give away that it's a web app.

I've found a few good methods that prevent this, but there is no way to do it on text inputs and textareas.

If there could be someway for you to turn this off, in config.xml, this would be amazing.

Please, please please look into this!

Thanks,
Jason
Photo of Jason Stallings

Jason Stallings

  • 63 Posts
  • 4 Reply Likes

Posted 9 years ago

  • 5
Photo of Andrew Lunny

Andrew Lunny

  • 1911 Posts
  • 199 Reply Likes
This is a good idea - I've added it to our internal todo list.
Photo of lejared

lejared

  • 4 Posts
  • 0 Reply Likes
How far is the implementation of this idea? We really need this, because the scroll-bounce completely destroys the feeling of a nativ App.
Photo of Andrew Lunny

Andrew Lunny

  • 1911 Posts
  • 199 Reply Likes
This has been implemented now, as documented here:
https://build.phonegap.com/docs/confi...

To disable the bounce, add the following tag to your config.xml file:

<preference name="webviewbounce" value="false" />


Please note this is only supported in apps running on PhoneGap 1.3.0 (and above)
Photo of Jason Stallings

Jason Stallings

  • 63 Posts
  • 4 Reply Likes
Awesome thanks!
Photo of Jason Stallings

Jason Stallings

  • 63 Posts
  • 4 Reply Likes
Btw it works perfectly! This is a huge improvement.

Thanks so much for the awesome service and support.
Photo of lejared

lejared

  • 4 Posts
  • 0 Reply Likes
The config.xml is only for https://build.phonegap.com/

How can I use this Option when i build my App with XCode?
Photo of Andrew Lunny

Andrew Lunny

  • 1911 Posts
  • 199 Reply Likes
I've contributed this PhoneGap patch to callback/cordova-iOS - you can find it here:
https://github.com/alunny/cordova-ios...

To add to a single app, add the following code to the ApplicationDidFinishLaunching method in the AppDelegate.m class:


if ([ self.webView respondsToSelector:@selector(scrollView) ]) {
((UIScrollView *) [self.webView scrollView]).bounces = NO;
} else {
for (id subview in self.webView.subviews)
if ([[subview class] isSubclassOfClass: [UIScrollView class]])
((UIScrollView *)subview).bounces = NO;
}


(this does not allow toggling with a preference - you will need the full patch for that)
Photo of lejared

lejared

  • 4 Posts
  • 0 Reply Likes
Thanks for your submission to Phonegap! I hope it will be included soon, so we can toggle this via options.

In my AppDelegate.m I can not found a ApplicationDidFinishLaunching methode. There is only a didFinishLaunchingWithOptions, but inserting your sniped there did not change anything. :-(
Photo of Francesco Trecani

Francesco Trecani

  • 2 Posts
  • 0 Reply Likes
I've the same problem as explained by lejared.
Any tips?
Thanks
Photo of Andrew Lunny

Andrew Lunny

  • 1911 Posts
  • 199 Reply Likes
Turns out you have to call the super method first - this works for me:


/**
* 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
{
NSURL* url = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey];
if (url && [url isKindOfClass:[NSURL class]])
{
self.invokeString = [url absoluteString];
}

BOOL superResult = [super application:application didFinishLaunchingWithOptions:launchOptions];

if ([ self.webView respondsToSelector:@selector(scrollView) ]) {
((UIScrollView *) [self.webView scrollView]).bounces = NO;
} else {
for (id subview in self.webView.subviews)
if ([[subview class] isSubclassOfClass: [UIScrollView class]])
((UIScrollView *)subview).bounces = NO;
}

return superResult;
}
Photo of Francesco Trecani

Francesco Trecani

  • 2 Posts
  • 0 Reply Likes
Thanks, this works smoothly.
Photo of lejared

lejared

  • 4 Posts
  • 0 Reply Likes
Great! Works like a charm. Thank you so much.
Photo of Lee Crossley

Lee Crossley

  • 12 Posts
  • 1 Reply Like
Can I do this in PhoneGap 1.4.1 ?
Photo of Andrew Lunny

Andrew Lunny

  • 1911 Posts
  • 199 Reply Likes
I don't think the patch made it in until PhoneGap 1.5.0 (next week) - you can either wait and upgrade then, or manually update the AppDelegate file, as suggested above.
Photo of Lee Crossley

Lee Crossley

  • 12 Posts
  • 1 Reply Like
Thanks Andrew. I could see your pull request wasn't in the latest code base on github, so I have monkey patched for now. Looking forward to 1.5.0.
Photo of zsprawl

zsprawl

  • 1 Post
  • 0 Reply Likes
Works great in 1.5. I didn't have to do anything because it was enabled in the plist file.
Photo of shemanov

shemanov

  • 11 Posts
  • 0 Reply Likes
Andrew Lunny latest answer didnt work for me after updating my project from phonegap 2.0.0 to phonegap 2.2.0.

Here, some from AppDelegate.m:

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
NSURL* url = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey];
NSString* invokeString = nil;

if (url && [url isKindOfClass:[NSURL class]]) {
invokeString = [url absoluteString];
NSLog(@"Wildberries launchOptions = %@", url);
}

//custom settings
if ([ self.viewController.webView respondsToSelector:@selector(scrollView) ]) {
((UIScrollView *) [self.viewController.webView scrollView]).bounces = NO;
} else {
for (id subview in self.viewController.webView.subviews)
if ([[subview class] isSubclassOfClass: [UIScrollView class]])
((UIScrollView *)subview).bounces = NO;
}
//custom settings end

CGRect screenBounds = [[UIScreen mainScreen] bounds];
self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease];
self.window.autoresizesSubviews = YES;
......

How can I stop webview bouncing when i build my App with XCode and phonegap 2.2.0?
Photo of Lee Crossley

Lee Crossley

  • 12 Posts
  • 1 Reply Like
There is a setting in your cordova.plist
UIWebViewBounce needs to be set to NO
Photo of shemanov

shemanov

  • 11 Posts
  • 0 Reply Likes
Thx very much, Lee. Now it stops bouncing!!!
Photo of Alex Grosu

Alex Grosu

  • 1 Post
  • 0 Reply Likes
Whe is cordova.plist located? cant find it. I'm using phonegap 2.5
Photo of shemanov

shemanov

  • 11 Posts
  • 0 Reply Likes
its only for iOs phonegap app
Photo of Pedro Lacueva

Pedro Lacueva

  • 1 Post
  • 0 Reply Likes
i use Cordova framework and nothing stop bouncing my app for me :(((((((

i dont know what i have to do any more, spent about 5 days and nights around this problem and i can`t figure out. :((((((

1o my plist file dont have any UIWebViewBounce line for i put to NO

2o In my config.xml i all ready try put this:

in my MainViewcontroller.m i all ready try to put this:

for (id subview in webView.subviews)
if ([[subview class] isSubclassOfClass: [UIScrollView class]])
((UIScrollView *)subview).bounces = NO;

OUR this

webView.scrollView.bounces = NO;
[[webView scrollView] setBounces: NO];

and dont work... just show me the small bullet error on the left, in xcode and i can`t even run my app in test device (iphone).

I Dont know what i have to do any more :( nothing work for i can enable the horror of bouncing efect.......

cheers :/
Photo of Amir

Amir

  • 8261 Posts
  • 263 Reply Likes
Topic more then a week old without further feedback.

Topic closed.

This conversation is no longer open for comments or replies.