我的网络视图应用程序无法向下滚动。我尝试使用这段代码:
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.isUserInteractionEnabled = true
而且效果会很好。
对于 webview 视图的滚动,您应该检查给定的三个步骤:
1)webview 视图应该是:
webView.userInteractionEnabled = true
2)webview 视图应该是:
webview.scrollView.scrollEnabled = true
3) webview 视图内容应该多于你的 webview 框架。