Reputation: 51
I have created an app that simply loads my pages into a UIWebView
in Swift 3. The problem is that pages seem to cache and do not reload any changes. Anyone know how to clear the cache or delete the file data when the app closes in Xcode 8/Swift 3?
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var MainWebView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
let url = NSURL(string: "http://www.webpage.com")
let request = NSURLRequest(url: url! as URL)
MainWebView.loadRequest(request as URLRequest)
}
}
Upvotes: 1
Views: 1814
Reputation: 716
You can set a CachePolicy
for the URLRequest
to ignore cached requests.
Documentation
Also, if your deployment target is iOS 8.0 and higher, try WKWebView instead of UIWebView
Edit:
Or you can just purge all UIWebView
URLRequest
Cache Documentation
Upvotes: 1
Reputation: 4107
You can try to call webView.reload() function to refresh your web view ?
Upvotes: 0