UIWebView 不滚动

UIWebView doesn't scroll

我的网络视图应用程序没有向下滚动。我试过这个代码:

webview.scrollView.scrollEnabled = true

但它不起作用。

我必须将我的 webview 应用程序放入滚动视图应用程序还是 webview 应用程序就足够了?我已经试过了,但直到现在还是不行。

我在 ViewController.swift 中的全部代码是:

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.
    }
}

只需在您的代码中添加这一行:

webView.userInteractionEnabled = true

它会很好用。

对于 webview 视图的滚动,您应该检查三个步骤:

1) webview 视图应该是:webView.userInteractionEnabled = true

2) webview 视图应该是:webview.scrollView.scrollEnabled = true

3) webview视图内容应该比你的webview frame多。