我想刪除我的應用程序的緩存。 我想通過使用UIWebView來顯示網頁。刪除應用程序的緩存
我當前的代碼:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var webBrowser: UIWebView!
webBrowser:(UIWebView *)webBrowser shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
override func viewDidLoad() {
super.viewDidLoad()
let url = NSURL(string:"http://127.0.0.1:8000/admin/accounts/")
let request = NSURLRequest(url:url! as URL)
self.webBrowser.loadRequest(request as URLRequest)
// Do any additional setup after loading the view, typically from a nib.
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
當我加入這個代碼
webBrowser:(UIWebView *)webBrowser shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
到視圖控制器,因此 「預期聲明」 的錯誤發生。 我的代碼有什麼問題? 我應該在某些時候連接我的Storyboard和這段代碼嗎? 我該如何解決這個問題?
行'web瀏覽器:(UIWebView的*)瀏覽器上shouldStartLoadWithRequest:(*的NSURLRequest)請求navigationType:(UIWebViewNavigationType)navigationType'你補充說,這是一個Objective- C代碼。在swift中轉換並再次運行代碼。 –
https://stackoverflow.com/a/40145732/6656894參考這個答案@ user8080149 –