【发布时间】:2015-03-25 19:01:58
【问题描述】:
我正在尝试在 Swift 中创建一个 WebView,并在 class AppDelegate: UIResponder, UIApplicationDelegate { 行上获取错误代码“线程 1:信号 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.
}
}
提前致谢!
【问题讨论】:
-
您的
WebView属性是否通过 Interface Builder 连接到 Web 视图? -
你能发布你的异常的整个堆栈跟踪吗?也尝试放置一个异常断点来推断。代码到底在哪里破坏