【发布时间】:2016-12-13 16:02:17
【问题描述】:
我实例化了一个 WebViewController 以模态方式呈现它(其中包含一个 webView 的 UIViewController)并尝试将当前类设置为其 webView 的委托,但这会导致应用程序崩溃。
let webVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "WebViewController") as! WebViewController
UIApplication.topViewController()?.present(webVC, animated: true, completion: {
webVC.webView.load(data, mimeType: response.mimeType!, textEncodingName: response.textEncodingName!, baseURL: response.url!)
webVC.webView.delegate = self
})
我尝试删除“vc.webView.delegate = self”部分,页面加载正常。有什么想法会导致这里出现问题吗?
【问题讨论】:
-
显示委托方法的实现。
-
当你崩溃时,堆栈跟踪是什么样的?
-
@shallowThought 现在是空的,所以我认为不是原因
-
@PhillipMills 已添加到问题中
-
您发布的代码是否在您的演示文稿
UIViewController中?发布更多代码以查看上下文。