UIWebView scrolls down

I use IUWebView as a chat window, and after adding a new message at the bottom of the window I want to scroll down the program, how can I do this?

+3
source share
3 answers

Inject this method into your UIWebView Delegate.

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [webView stringByEvaluatingJavaScriptFromString:@"window.scrollTo(document.body.scrollWidth, document.body.scrollHeight);"];
}
+3
source

Have you tried something like this:

[mywebview stringByEvaluatingJavaScriptFromString:@"window.scrollTo(x, y);"]
+2
source

, UIWebView , -

NSArray *views = [NSArray arrayWithArray:[self.webview subviews]];
self.scrollview = (UIScrollView *)[views objectAtIndex:0];

self.scrollview.delegate = self, , UIScrollView, google " UIScrollView", , . , .

+1

Source: https://habr.com/ru/post/1725945/