2017-06-23 23 views
-2

」期望的參數名稱後跟':''的錯誤會多次發生。 我想從我的UIWebView系統中刪除緩存。 我寫的ViewController像「預期的參數名稱後跟':''的錯誤多次發生

import UIKit 
    class ViewController: UIViewController,UIWebViewDelegate { 

     @IBOutlet weak var webBrowser: UIWebView! 

     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.delegate = self 
      self.webBrowser.loadRequest(request as URLRequest) 
      URLCache.shared.removeAllCachedResponses() 
      URLCache.shared.diskCapacity = 0 
      URLCache.shared.memoryCapacity = 0 
     } 

     func webView(_webBrowser,;: UIWebView, 
        shouldStartLoadWith, request: URLRequest, 
        navigationType: UIWebViewNavigationType) -> Bool 


    override func didReceiveMemoryWarning() { 
     super.didReceiveMemoryWarning() 
     // Dispose of any resources that can be recreated. 
    } 


    } 

但在這部分

func webView(_webBrowser,;: UIWebView, 
      shouldStartLoadWith, request: URLRequest, 
      navigationType: UIWebViewNavigationType) -> Bool 

許多錯誤發生像 many errors

Xcode的建議我如何修復這些錯誤,例如 「修復它插入」 _ :「」,但如果我命令這些方法來解決這些錯誤,則會發生其他錯誤。所以,我無法修復它們。 我該如何解決它們?我認爲我在語法上犯了一個錯誤,但我不知道它在哪裏。

回答

1

。在你的代碼的兩個錯誤:

  1. 你沒有把該方法的{}和該方法預計會返回一個bool
  2. 並且最重要的問題是您寫入的函數簽名完全是錯誤的

因此,要使用該功能,正確的方法是這樣的:

func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool 
{ 
    return true 
} 
0

原因語法error.update您的委託方法喜歡下面

func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool 
{ 
    return true 
} 
+0

@downvotter我更新我的回答 –

相關問題