0

I am using this code to stop uiwebview bounces vertically and its work fine in simulator 4.0.But when i installed my app in my first generation ipod it wont work.

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

Can anyone help me? Is there any reason beyond this ?

Thanks in advance......

dragon
  • 1
  • 6

3 Answers3

0

I had the same problem and as mentioned, there have been numerous answers. Unfortunately none of them worked for me. I however got a way to work around it.

On the CDViewController.m file, you should add the following when the view is being instantiated. That should work. If not, check out the other answers here Stop UIWebView from "bouncing" vertically?

if (!self.webView) {
        [self createGapView];
        webView.delegate = self;
        webView.scalesPageToFit = YES;
        [[webView scrollView] setBounces:NO];
    }
Community
  • 1
  • 1
Nyamor
  • 1
0

You have to define your bounce settings in the webViewDidFinishLoad function.

I fixed it in my webview delegate view controller by this way :

-(void) webViewDidFinishLoad:(UIWebView *)webView
{
     [[_webView.subviews objectAtIndex:0] setBounces:NO];
}

I hope it will help you :)

tryp
  • 1,120
  • 20
  • 26
0

I'm having the same problem on my iPhone running 3.1.3 (building with iOS 4.1 SDK).

There is a lot of discussion on the issue in this question (but I haven't found a solution that works for me yet):
Stop UIWebView from "bouncing" vertically?

As a workaround I tried setting the background colour so the bounce would match the white background of my HTML being displayed. Unfortunately you get left with a grey gradient that still looks bad. Somebody else has asked how to solve that issue here (but no answers yet):
Remove gradient background from UIWebView?

Community
  • 1
  • 1
Dan J
  • 25,433
  • 17
  • 100
  • 173
  • You can disable bounces once your HTML loads by executing `preventDefault()` against Javascript move events. – Justin Oct 22 '10 at 02:15