gpt4 book ai didi

ios - uiwebview页面底部自动滚动

转载 作者:行者123 更新时间:2023-11-28 20:47:33 27 4
gpt4 key购买 nike

我希望一旦 webview 加载

- (void)webViewDidFinishLoad:(UIWebView *)webBrowser {
//Scroll to bottom
}

只关注底部,所以基本上只显示到 uiwebview 的底部,并可能将其锁定在那里,这样用户就无法滚动。

最佳答案

首先你必须获得内容高度,我个人从来没有这样做过,但是here是一个很好的起点:

Here are some constants available that give the document area of the window that is available for writing to. These will not be available until after the document has loaded and the method used for referencing them is browser specific. The available constants are:

window.innerHeight/Width Provided by most browsers, but importantly, not Internet Explorer. document.body.clientHeight/Width Provided by many browsers, including Internet Explorer. document.documentElement. clientHeight/Width Provided by most DOM browsers, including Internet Explorer.

然后像这样滚动到你想要的偏移量:

[webView stringByEvaluatingJavaScriptFromString: [NSString stringWithFormat:@"scrollTo(0,%d)",scrollPosition]; 

关于ios - uiwebview页面底部自动滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4365752/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com