4

One of the modules of my app is a web site. That web site contains primarily an SVG drawing, with custom shaped buttons (using Raphael.js library) to access other drawings (other html page with svg drawings).

If the device is on iOS 7, I use a UIWebView and everything works fine.

For iOS 8 devices, I use a WKWebView. I had some issues, some of them resolved by this post. I can see my web site on those simulators (iPhone 5 / iOS 8.0 (12A365) & iPhone 5s / iOS 8.0), but I can't see it on my iPod Touch (5th gen, running iOS 8.0.2). It shows a blank screen.

I don't know what to look for. Any idea?


EDIT

After following @Dan Fabulich's answer (here), I now get a forever-loading webview, that never finishes loading up. His answer tells us that there is a bug with WKWebView when loading html from a string. His answer is to copy the html content into a new subfolder and then call loadRequest from that URL.

Unfortunately, I'm still stuck with a non-working webview. Any clue? What would be a reason for a webview to never finish loading up content?

Community
  • 1
  • 1
invalidArgument
  • 2,289
  • 4
  • 24
  • 35
  • 2
    I believe copying to the documents folder doesn't work; I think only copying to the temporary folder (`NSTemporaryDirectory()`) gets around the bug. – SeanR Oct 20 '14 at 06:06
  • IMO, this isn't a general enough question to be answered on StackOverflow. It does indeed sound like you're getting bit by the bug reported in my answer, but there's nothing in general to add to my answer. (Note that I didn't write the workaround code; shazron did.) My only advice is to try getting shazron's workaround project to work. If that works, then you have something that works, and something that doesn't; careful scrutiny and experimentation should help you find the difference. – Dan Fabulich Oct 20 '14 at 07:41
  • I am seeing the same problem but with: NSURLRequest * request = [NSURLRequest requestWithURL:url]; [webView loadRequest:request]; – user3246173 Oct 20 '14 at 16:06
  • Was this ever solved? I am experiencing same result with XHTML files. While HTML files are loading correctly on simulator and device. – coder Aug 22 '20 at 06:39

1 Answers1

0

i had some problem but i solved problem with configuration options. here is my my code.

    var a = dic["adi"]?.asString()
    var path = NSBundle.mainBundle().pathForResource(a, ofType: "htm" )
    var url = NSURL(fileURLWithPath:path!)
    var request = NSURLRequest(URL:url!)

    var theConfiguration = WKWebViewConfiguration()

    theWebView = WKWebView(frame:self.view.frame, configuration: theConfiguration)

    var error:NSError?
    let text2 = String(contentsOfFile: path!, encoding:NSUTF8StringEncoding, error: &error)

    if let theError = error
    {
        print("\(theError.localizedDescription)")
    }

    theWebView!.loadHTMLString(text2!, baseURL: nil)
    self.view.addSubview(theWebView!)

hope this helps.

ardacankaya
  • 211
  • 1
  • 4
  • 14