Daniela Donna
Daniela Donna

Reputation: 270

UIWebView doesn't scroll

My webview app doesn't scroll down. I tried with this code:

webview.scrollView.scrollEnabled = true

but it doesn't work.

Must I to put my webview app into a scrollview app or the webview app is enough? I already tried it but it doesn't work until now.

My whole code in ViewController.swift is:

import UIKit

class ViewController: UIViewController {

    @IBOutlet var webView: UIWebView!

    override func viewDidLoad() {
        super.viewDidLoad()

        //creo una costante di tipo NSURL
        let url = NSURL(string: "http://www.apple.com")

        //creo una richiesta di accesso a quello specifico indirizzo
        let request = NSURLRequest(URL: url!)

        //abilito lo zoom nella webView
        webView.scalesPageToFit = true
        webView.scrollView.scrollEnabled = true

        //carico la richiesta a quell'URL e aggiorna la WebView
        webView.loadRequest(request)

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

Upvotes: 6

Views: 8861

Answers (2)

Dharmesh Kheni
Dharmesh Kheni

Reputation: 71852

Just add this line in your code:

webView.isUserInteractionEnabled = true

And it will work fine.

Upvotes: 7

Alok
Alok

Reputation: 25968

For scrolling of webview view you should check given three step :

1) webview view should be : webView.userInteractionEnabled = true

2) webview view should be : webview.scrollView.scrollEnabled = true

3) webview view content should be more than your webview frame .

Upvotes: 7

Related Questions