使用 Swift 在 WebView 中获取空白屏幕 [英] Getting Blank Screen in WebView using Swift
本文介绍了使用 Swift 在 WebView 中获取空白屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Swift 3
制作一个简单的 webview
.但运行后只得到空白屏幕.
I am making a simple webview
using Swift 3
. But after run am getting only the blank screen.
它没有打开我在 url 请求中输入的链接.
It is not opening the link which I put in url request.
import UIKit
class ViewController: UIViewController {
@IBOutlet var webView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
let url = URL (string: "http://www.google.net");
let request = URLRequest(url: url!);
webView.loadRequest(request);
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
推荐答案
webView.loadRequest(request as URLRequest)
试试这个可能会有帮助..
try this it might help..
这篇关于使用 Swift 在 WebView 中获取空白屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文