Cache a single webpage for use when offline in Xcode / UIWEBVIEW

落爺英雄遲暮 提交于 2019-12-11 03:27:24

问题


I have a UIWEBVIEW that connects to a "login.php?email=a@b.com&password=aaa"

Login .php uses these details to login to an external website and fetch and display its contents using CURL.

I have got my login.php to store the webpage into a folder "/cache/a@b.com.html" on my webserver.

I now need to find a way to tell Xcode / UI webview

If there is an internet connection: -Visit login.php -Download latest /cache/a@b.com.html and store local.

If there isnt an internet connection: -Load local 'a@b.com.html' file.

I hope you understand,

I have looked at some systems out there such as: http://robnapier.net/blog/offline-uiwebview-nsurlprotocol-588

But that stores the file that your UIWEBVIEW visits which in my case is 'login.php'.

Thanks,

Jack.


回答1:


I never managed to complete the task this way, by did make use of the RNCachingURLProtocol at https://github.com/rnapier/RNCachingURLProtocol/blob/master/RNCachingURLProtocol.h



来源:https://stackoverflow.com/questions/13964713/cache-a-single-webpage-for-use-when-offline-in-xcode-uiwebview

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