0

I'm having an issue with setScrollsToTop: on UIWebView. the webview is a subview of the root view controller and on viewDidLoad I set:

[self.webView.scrollView setScrollsToTop:YES];

However when I then tap the status bar the webview won't scroll to the top. On another modal tableViewController inside the app it works fine, without even setting setScrollsToTop:YES. This is the code in applicationDidFinishLaunching inside the app delegate:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.f = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
self.window.rootViewController = self.f;
[self.window makeKeyAndVisible];
return YES;

How can I make it work?

EDIT: It seems like a UIScrollview that is in the same view is causing the problem. How can I make it work with the UIScrollView?

JonasG
  • 9,274
  • 12
  • 59
  • 88
  • For clarification: Do you mean that by tapping on status bar, you want the HTML page that is being loaded in UIWebView, scroll to top? Right? – Sierra Alpha Jan 10 '12 at 14:35

3 Answers3

2

Try setting setScrollsToTop:NO on the UIScrollView.

According to the docs on setScrollsToTop: in UIScrollView,

This gesture works on a single visible scroll view; if there are multiple scroll views (for example, a date picker) with this property set, or if the delegate returns NO in scrollViewShouldScrollToTop:, UIScrollView ignores the request.

Tommy
  • 594
  • 5
  • 8
0

use the answer here: UIScrollView + UIWebView = NO scrollsToTop

worked for me like a charm.

i had a UIScrollView with a UIWebView embedded.

Community
  • 1
  • 1
faterpig
  • 344
  • 1
  • 6
0

Maybe those code will solve you problem if I get the problem.

self.automaticallyAdjustsScrollViewInsets = NO;

CGSize containerSize = self.view.frame.size;
self.webView.frame = CGRectMake(0, 64, containerSize.wdith, containerSize.height - 65);

Sometime the self.automaticallyAdjestsScrollViewInsets is not wokring as usual. So, just turn off it.

Hope
  • 11
  • 1