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?
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.
use the answer here: UIScrollView + UIWebView = NO scrollsToTop
worked for me like a charm.
i had a UIScrollView with a UIWebView embedded.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.