Determine if images are loaded in UIWebView?

I have a UIWebview that uploads an image. However, I am trying to call the method when the image has finished loading / displaying.

I tried using UIWebViewDelgate and used

-(void)webViewDidFinishLoad:(UIWebView *)webView {} 

However, this method is called before loading / displaying the image. How can I fix this. Any help would be greatly appreciated.

Josh

+4
source share
2 answers

Unfortunately, the delegate you mentioned does not get called for every HTTP request, but rather for every page.

You should be able to receive notifications when a specific URL is processed by a subclass of NSURLProtocol . There is a related answer that describes how to replace deleted images with local images in UIWebView . This should give you an idea of ​​how to implement your subclass of NSURLProtocol .

0
source

I think the best way is to use javascript to call any known url through window.location.href='myurl://imageLoaded' , which will be intercepted in the webView shouldStartLoadingRequest

there is a way to set a script for the onload Javascript event that runs after the page loads

0
source

Source: https://habr.com/ru/post/1305489/


All Articles