我的webview应用程序无法向下滚动。我试过这段代码:
webview.scrollView.scrollEnabled = true
但它不起作用。
我必须将我的webview应用程序放入scrollview应用程序或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.
}
}
答案 0 :(得分:6)
只需在代码中添加以下代码:
webView.userInteractionEnabled = true
它会正常工作。
答案 1 :(得分:6)
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 .