P
P
progmax2015-09-05 17:36:09
iOS
progmax, 2015-09-05 17:36:09

Ios 8.4.1 webview displays a black screen, what could be the problem?

I need to make a statement in IOS in a simple WebView. I am using example . Recently upgraded to IOS 8.4.1. After the update, the application stops working, a black screen is displayed.

import UIKit
import WebKit

class ViewController: UIViewController, WKNavigationDelegate {
  var webView: WKWebView?
  
  /* Start the network activity indicator when the web view is loading */
  func webView(webView: WKWebView,
    didStartProvisionalNavigation navigation: WKNavigation){
      UIApplication.sharedApplication().networkActivityIndicatorVisible = true
  }
  
  /* Stop the network activity indicator when the loading finishes */
  func webView(webView: WKWebView,
    didFinishNavigation navigation: WKNavigation){
      UIApplication.sharedApplication().networkActivityIndicatorVisible = false
  }
  
  func webView(webView: WKWebView,
    decidePolicyForNavigationResponse navigationResponse: WKNavigationResponse,
    decisionHandler: ((WKNavigationResponsePolicy) -> Void)){
    
      print(navigationResponse.response.MIMEType)
      
      decisionHandler(.Allow)
      
  }
  
  override func viewDidLoad() {
    super.viewDidLoad()
    
    /* Create our preferences on how the web page should be loaded */
    let preferences = WKPreferences()
    preferences.javaScriptEnabled = false
    
    /* Create a configuration for our preferences */
    let configuration = WKWebViewConfiguration()
    configuration.preferences = preferences
    
    /* Now instantiate the web view */
    webView = WKWebView(frame: view.bounds, configuration: configuration)
    
    if let theWebView = webView{
      /* Load a web page into our web view */
      let url = NSURL(string: "http://www.apple.com")
      let urlRequest = NSURLRequest(URL: url!)
      theWebView.loadRequest(urlRequest)
      theWebView.navigationDelegate = self
      view.addSubview(theWebView)
      
    }
    
  }
  
}

If any working sample code?
Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question