UIWebView content height not accurate in scrollview.contentsize

ⅰ亾dé卋堺 提交于 2019-12-05 02:11:06

to get the content size or the number of pages contained in the webview you may do the following:

    float w = [[mywebview stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('html')[0].scrollWidth;"] floatValue];
    int pageCount = ceil(w/self.view.frame.size.width);

and to scroll to a certain position in your webview you may do the following:

    [mywebview stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"window.scrollTo(%d,0);",xPosition]];

You find it useful.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!