WKWebView: Is it possible to preload multiple URLs?

爱⌒轻易说出口 提交于 2019-12-01 09:32:50

I ended up just using NSURLCache and preloading all URLs using NSURLRequest and NSURLConnection. Then whenever I load a url into WKWebView it uses the cached requests per my cache policy.

A relatively straight-forward way to do this is to create five NSData objects (asynchronoulsly), each initialized using the known urls. When you need to display one of them, you can convert the NSData to a string, and then call WKWebView's loadHTMLString function to change the displayed page.

You can also preload five different WKWebView instances and swap them in/out when you need a specific URL. This depends on your UI and interaction of course.

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