2015-09-21 12 views
0

我希望我的UIWebView來時,有過中斷或干擾與負載顯示警報視圖錯誤信息,我已經試過執行下面的代碼,但它是不成功的:如何正確實現UIWebView'didFailLoadWithError'警報視圖?

func webView(webView: UIWebView, didFailLoadWithError error: NSError?) { 
     let myAlert = UIAlertController(title: "Alert", message: error?.localizedDescription, preferredStyle: UIAlertControllerStyle.Alert) 
     myAlert.showViewController(myAlert, sender: self) 
    } 

是有什麼關於無效這種方法,如果有的話,我應該如何糾正它?

回答

2

替換:myAlert.showViewController(myAlert, sender: self)

有了這個:self.presentViewController(myAlert, animated: true, completion: nil)