我正在尝试在Swift中创建一个WebView,并在class AppDelegate: UIResponder, UIApplicationDelegate {行得到错误代码“Thread1: signal SIGABRT
我的代码如下(变量"theURL“有一个真实的URL):
import UIKit
class ViewController: UIViewController {
@IBOutlet var Webview: UIWebView!
var theURL = "URL"
func loadWebPage() {
let theRequestURL = NSURL (string: theURL)
let theRequest = NSURLRequest(URL: theRequestURL!)
Webview.loadRequest(theRequest)
}
override func viewDidLoad() {
super.viewDidLoad()
loadWebPage()
// 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.
}
}提前感谢!
发布于 2015-03-26 05:52:36
您必须将此页面链接到您的Main.Storyboard。您可以在Main.Storyboard中使用Web视图。
发布于 2016-09-06 12:45:26
我知道这个问题是很久以前出现的,但我也遇到了完全相同的问题,我通过检查main.storyboard文件中的插座连接解决了这个问题。我从代码中删除了插座,但没有从main.storyboard中删除。单击所有视图并检查其插座连接。
发布于 2020-02-03 21:32:55
这将解决问题,我希望:)
class ViewController: UIViewController, WKUIDelegate {
...
webView.uiDelegate = self
...
}请查看此链接:https://developer.apple.com/documentation/webkit/wkwebview#2560973
https://stackoverflow.com/questions/29264310
复制相似问题