Best practice for offline website in iOS

前端 未结 3 1834
南旧
南旧 2020-12-28 10:39

I\'m building an app that requires downloading a lot of html5 content. Essentially it works similar to the magazine apps you see for iPad, except instead of using images, i

3条回答
  •  甜味超标
    2020-12-28 11:19

    You could download first an file that reflects the structure of the website images, css, htmls.

    Then you parse this file and start download each file and save them to documents directory (you don't save in database because you could have big images and that will be slow you could save the paths of them). Afther thad just do an request to the local html.

    Edit: You can catch the request in the webView delegate and see if it is internal or external

    webView:shouldStartLoadWithRequest:navigationType: Sent before a web view begins loading content.

    • (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType

    UIWebViewDelegate Protocol Reference

提交回复
热议问题