Jonathan Allen Grant
Jonathan Allen Grant

Reputation: 3648

Swift: Automatically scroll down to a point on UIWebView

I want to use UIWebView to show a website, but it has things at the top I do not wish to show. How can I make the UIWebView immediately scroll to a certain part of the website?

Upvotes: 2

Views: 1773

Answers (1)

Glorfindel
Glorfindel

Reputation: 22641

UIWebView has a scrollView property:

You can set its content offset like this:

webView.scrollView.contentOffset = CGPoint(0, 200)

An alternative might be to add the ID of a specific element to the URL, like this: https://stackoverflow.com/#h-top-questions

Upvotes: 4

Related Questions