display url in WKWebView when partially loaded - ios

I have recently started working with WKWebViews. When loading a url the WKWebView appears to wait for all javascript to complete before it shows any of the page. Is there a way to allow the WKWebView to load content progressively like it does in a UIWebView. Thanks

Related

Why does React Native webview fails to load images when opened second time?

I am rendering remote images inside a webview in react native ios.
The image tag looks like this
<img src="https://example.in/1222asdasdas.png" alt="bug-tracking-tips-01">
The webview loads the images from the remote url and everything works fine the first time I load the webview.
But the next time I open the webview the image does not appear and when I inspect in safari, this error is shown An error occured trying to load the resource.
An interesting thing however is that if I have multiple instances of webview, each webview loads images for the first time and fails in the successive trials.
How can this be solved?

Url redirection is not working for WKWebview , where as working for UIWebview

When I am load a embedded html content using UIWebview
UIWebView.loadRequest() , the page load is happening .
Although when loading the same content using WKWebview page is not loading properly. I have checked the redirection url from decidePolicyFor navigationAction delegate method and they are same as UIWebview.
Any suggestion will be helpful.

WKWebView shows white screen for a long time after start request

I'm using WKWebView to load a local html file using
[self.webView loadFileURL:tmpUrl allowingReadAccessToURL:directoryUrl];
Currently the webView will keep white screen for a long time, and once it shows content, all images were already downloaded.
It looks like the WKWebView will only render after all images downloaded.
Sample HTML content is here: https://pastebin.com/681btcSa
Then I did some test for pages without images. It seems that when loading complex HTML, WKWebView always takes a long time before render anything on screen.
I tried to call _updateVisibleContentRects and setNeedsLayout, but it helps little.

Safari opens pages but web view is not

I am using UIWebView to load a page, the page to load is made with ajax asynchronous, I don't know why, my UIWebView is not able to load the page, but Safari is able to load the same.
Any help related to the same is appreciated!!
Thanks

How to avoid a blink when UIWebView loads HTML

I have a native iOS app that contains a tab bar. The view controller for each tab contains a UIWebView. When the user switches between tabs, I load the HTML in the corresponding web view. The HTML is fully cached on a device. Here is how I feed the HTML to UIWebView:
[self.webView loadHTMLString:htmlString baseURL:baseUrl];
baseUrl is a file URL pointing to a directory where all assets are located.
This works great in online and offline modes, however it takes time for the UIWebView to parse and render the HTML. As a result, the user sees a brief blink of a white background when switching between tabs. I'd like to remove it, because the user is able to tell that the UI is not native (native UI renders instantly).
I was thinking about taking a screenshot of the UIWebView once it's done rendering the HTML and caching it in memory. The next time the user navigates to that web view, the app displays the screenshot while the UIWebView is rendering the HTML in the background. Finally, the app swaps the screen shot with the actual UIWebView and takes a new screenshot. This is similar to how Google Chrome app works.
Does anyone know a better solution to this problem?
Depends on how you present that web view. I'm not really sure from your description how you do it, but since you're talking about a blink of white background, I'm going to assume there is a situation where you have a web view with a loaded html and then you switch it to another html. The solution for that case would be:
create a second web view,
load the new html to this new web view,
when that web view finishes loading html (you can find out if you use UIWebViewDelegate) you can then quickly switch it with your old web view (meaning you finally add the new web view to the view hierarchy at THIS point, not when you created it).
This way you'll have an instant switch between old and new html, however user will be left waiting and it is your decision what to do with it. You could use UIActivityIndicatorView for example.
When webViewDidFinishLoad: gets called you can do any number of things, make the webview visible, remove something that you had on top of the webview etc...

Resources