Farid Valiyev Farid Valiyev - 6 months ago 34
iOS Question

How to Stop UIWebView from “bouncing” vertically scrolling bottom?

My question is the same as this question, but has one difference. When I scroll to top refresh my website, I want stop bouncing only to the end of the bottom scroll. How do I do this?

Answer

You can try like this :

override func viewDidLoad() {
    super.viewDidLoad()

    webview.scrollView.delegate = self

}

func scrollViewDidScroll(scrollView: UIScrollView) {

    if (scrollView.contentOffset.y >= scrollView.contentSize.height - scrollView.frame.size.height) {
        scrollView.setContentOffset(CGPointMake(scrollView.contentOffset.x, scrollView.contentSize.height - scrollView.frame.size.height), animated: false)
    }   
}

Set the delegate of your webview and set the content offset of the webview's scrollview

Ref taken from: http://stackoverflow.com/a/14084747/4557505