ios - 如何正确实现 UIWebView 'didFailLoadWithError' 警报 View ?

标签 ios swift error-handling uiwebview

我希望我的 UIWebView 在出现负载中断或干扰时显示警告 View 错误消息,我已尝试实现以下代码,但未成功:

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

此方法是否存在无效问题?如果是,我应该如何更正?

最佳答案

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

有了这个:self.presentViewController(myAlert, animated: true, completion: nil)

关于ios - 如何正确实现 UIWebView 'didFailLoadWithError' 警报 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32703033/

相关文章:

ios - 如何从点击的单词 UITextview 中获取字符范围

swift - 使用 Alamofire 快速上传图像和参数

swift - Swift 中如何判断两个对象是否属于同一类型

c# - 站点不工作 如果功能不工作则出错

ios - SKMutablePayment 属性 : applicationUsername

ios - 更改字体大小以完全适合按钮内的文本?

ios - Phonegap 3.4 文件传输错误 (iOS)

swift - 解析collectionView中的显示图像

mysql - #1064-您的SQL语法: MAX NULL problem错误

java - 更改 JAVA Eclipse 中的编译器版本会导致交替出现错误