Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing a WkWebview between requests

I have a native segment control that loads predetermined URLs in a WKWebView. What I want to achieve is the WKWebView clearing (is blank) between loads.

So right before I fired off the real request, I tried to load:

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]];
[wkWebView loadRequest:request];

I even tried to load some empty HTML to no avail:

[wkWebView loadHTMLString:@"<html><body></body></html>" baseURL:[NSURL URLWithString:@"about:blank"]];

This does work for UIWebView. Any tips on this one?

like image 677
ABeanSits Avatar asked Nov 09 '22 21:11

ABeanSits


1 Answers

It's possible via delegates. Just hide your webview before each request and turn it visible after load completion.

like image 158
Fernando Martínez Avatar answered Nov 14 '22 22:11

Fernando Martínez