There is a WebView that should display a page from html code. (Via loadHTMLString). I had to make certain code viewDidLoad I loaded it, so in viewDidLoad I added the line webView.delegate = self , added UIWebViewDelegate controller class UIWebViewDelegate , and added webViewDidFinishLoad and webView(... shouldStartLoadWithRequest request: NSURLRequest, ...) to the class webView(... shouldStartLoadWithRequest request: NSURLRequest, ...) , but, having started the program, I saw that all the CSS had flown somewhere. I removed the line with the delegate , everything returned to its place, but the webViewDidFinishLoad method stopped being called ... I rummaged through the whole Internet, I did not find anything on this topic ... What should I do? Can anyone come across such a problem?

You asked for a delegate code. I decided to provide all the code, I just cut off something that definitely does not affect the problem, and, out of habit, I commented on everything in English =) I hope for your help: http://swiftlang.ng.bluemix.net/#/repl/ 58850ee5b90d0e34734a8f27

  • show what code is executed in delegate methods - Max Mikheyenko
  • @MaxMikheyenko Delegate code? Do you mean the controller class code? - Pretzel
  • @MaxMikheyenko Just for your sake =) - Pretzel
  • you can throw out the whole project on githabs - Max Mikheyenko
  • @MaxMikheyenko This, in essence, is the whole project. All the rest is optional. In addition, I am afraid that they will cast slippers over my nubocode. - Pretzel

1 answer 1

In your code, you always return false when you try to start loading a new page into webView. You need to return false in if and true outside

 func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool { if(request.url?.scheme=="t") { var str = request.url?.query str = str!.substring(from: (str!.characters.index(str!.startIndex, offsetBy: 2))) ((self.parent as! TabBarViewController).customizableViewControllers![1] as! WebViewController).filePreviewObject.stringByEvaluatingJavaScript(from: "console.EasyHTML.consoleMessages[\(str!)][5]=!console.EasyHTML.consoleMessages[\(str!)][5]") return false } return true }