0
votes

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?

3
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?Canopus

3 Answers

2
votes

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.

0
votes

use the answer here: UIScrollView + UIWebView = NO scrollsToTop

worked for me like a charm.

i had a UIScrollView with a UIWebView embedded.

0
votes

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.