https://github.com/logisticinfotech/webview-clean-content
https://github.com/logisticinfotech/webview-clean-content
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/logisticinfotech/webview-clean-content
- Owner: logisticinfotech
- Created: 2018-06-21T14:52:52.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-30T15:07:46.000Z (over 7 years ago)
- Last Synced: 2025-01-02T07:10:12.967Z (about 1 year ago)
- Language: Objective-C
- Size: 320 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# webview-clean-content

## Introduction
Sometimes we may need to clear content loaded on our UIWebView as per our requirements and optimisations.
Generally to do this we will load blank html page without any content but it will take time and load to load html page.
Instead we can easily accomplish this by just single line of Javascription code.
You can find step by step guide from [this blog](https://www.logisticinfotech.com/blog/clean-uiwebview-content)
Here is code for that for Objective C and Swift both.
## Objective C
```
NSString *urlString = @”https://www.google.com/”;
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[_webView loadRequest:urlRequest];
```
## Swift
```
let url = URL(string: “about:blank”)
let requestObj = URLRequest(url: url! as URL)
webView.loadRequest(requestObj)
```