WKWebViewを再描画することができません。
再セットしたい場面で一度webView.removeFromSuperview()でSubViewを削除し、
以下のメソッドを呼ぼうとしたのですが、エラーが発生します。
func arrangement(){ let deviceBound : CGRect = UIScreen.mainScreen().bounds let configuration: WKWebViewConfiguration = WKWebViewConfiguration() configuration.processPool = WKProcessPool() … webView = WKWebView(frame: CGRectMake(0, 20, deviceBound.size.width, deviceBound.size.height), configuration: configuration) webView.allowsBackForwardNavigationGestures = true webView.navigationDelegate = self webView.UIDelegate = self self.view.addSubview(self.webView) }
エラー内容は以下の通りです。
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x15c60e160 of class WKWebView was deallocated while key value observers were still registered with it.
libc++abi.dylib: terminating with uncaught exception of type NSException
エラーが発生する場所は以下の通りです。
webView = WKWebView(frame: CGRectMake(0, 20, deviceBound.size.width, deviceBound.size.height), configuration: configuration)
WebViewセット時にJavaScriptも付加させているため、ロードではなく再描画を行いたいと考えています。
エラーの原因、より良い実装方法があればご教授いただけると幸いです。
回答1件
あなたの回答
tips
プレビュー