Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.
    }
}
like image 320
Daniela Donna Avatar asked Aug 14 '15 09:08

Daniela Donna


1 Answers

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 .

like image 116
Alok Avatar answered Oct 30 '22 07:10

Alok