On previous versions of IOS the following code works
- (void)webViewDidFinishLoad:(UIWebView *)webView {
int height = ([self.page intValue] - 1) * pageHeight;
if (isProCards)
height = ([self.page intValue] - 1) * proPageHeight;
NSString *script = [NSString stringWithFormat:@"window.scrollTo(0, %d);", height];
[self.web stringByEvaluatingJavaScriptFromString:script];
}
It no longer works on IOS5. Does anyone know any other way of getting a webview to scroll when displaying a PDF?
Thanks,
Joe
PS I have confirmed that javascript still runs, its just that scrolling doesn't work.
The UIScrollView
is exposed in IOS5, this means that you can do this:
[web.scrollView setContentOffset:CGPointMake(0, offset)];
The only caveat is that this can't be called from the webViewDidFinishLoad
method. You have to use an NSTimer
to execute the code after the web view has loaded and is scrollable.
Joe
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.