UIWebView cannot read correctly some local HTML5 stuff

依然范特西╮ 提交于 2019-12-12 01:49:51

问题


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:

  1. Embed a web server into your app (I prefer GCDWebServer)
  2. Let GDCWebServer serve your storyline locally with: [webServer startWithOptions:@{@"BindToLocalhost": @YES} error:nil];
  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!