0
有没有方法根据当前URL更改UIWebView的滚动位置?根据URL更改UIWebView滚动位置
例如:
if (webView = thisURL) {
webView scrollPosition = ...
}
elseif (webView = thisURL) {
webView scrollPosition = ...
}
感谢
有没有方法根据当前URL更改UIWebView的滚动位置?根据URL更改UIWebView滚动位置
例如:
if (webView = thisURL) {
webView scrollPosition = ...
}
elseif (webView = thisURL) {
webView scrollPosition = ...
}
感谢
落实UIWebViewDelegate,然后做出这样的事情:
-(void) webViewDidFinishLoad:(UIWebView *)webView{
NSString *currentURL = webView.request.URL.absoluteString;
if([currentURL isEqualToString:@"http://www.foo.com/uri"])
[webView stringByEvaluatingJavaScriptFromString:@"scrollTo(100,100);"];
}
它惹人在Web视图中显示的CURREN URL,然后将其进行比较到另一个url,如果比较返回true,则当前的webview会触发一个调用scrollTo()函数的JavaScript。
相关:[如何在UIWebView中设置内容偏移和内容大小](http://stackoverflow.com/questions/3525256/how-to-set-content-offset-and-content-size-in-a --uiwebview) – iDev
可能重复[如何在uiwebview上设置滚动位置](http://stackoverflow.com/questions/8470991/how-to-set-scroll-position-on-uiwebview) – Mark
Webview有一个名为scrollView的属性改变滚动视图的偏移量就像; webview.scrollView.contentOffset = CGPointMake(100,0) – Sandeep