问题
Here I come with a new challenge for you all, Objective-C developers:
I'm trying to load some HTML5 exports from Articulate into an UIWebView. Well, at first sight it's quite simple: just put the HTML5 resources into the project and call index.html.
Well, that simply doesn't work if the HTML5 resource have a complex javascript structure. Specially with <audio>
and <video>
tags.
Any idea?
回答1:
I've been investigating for hours and the solution appeared with some lateral thinking:
If the main problem is that reading locally doesn't work, but the app requirements forces you to maintain the content offline, then let's serve the content locally!.
Here are the steps I followed to resolve this issue:
- Embed a web server into your app (I prefer GCDWebServer)
- Let GDCWebServer serve your storyline locally with:
[webServer startWithOptions:@{@"BindToLocalhost": @YES} error:nil];
- Use
WKWebView
to call your local web server with:[wkView loadRequest:[NSURLRequest requestWithURL:webServer.serverURL]];
Then you will see your Articulate storyline working perfectly in your app inside a window, with iOS8.
Hope this can help someone.
来源:https://stackoverflow.com/questions/29789953/uiwebview-cannot-read-correctly-some-local-html5-stuff