【问题标题】:how to correctly implement UIWebView 'didFailLoadWithError' alert view?如何正确实现 UIWebView 'didFailLoadWithError' 警报视图?
【发布时间】:2015-09-21 19:23:59
【问题描述】:

我希望我的 UIWebView 在负载出现中断或干扰时显示警报视图错误消息,我尝试实现以下代码,但没有成功:

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

这种方法有什么不妥之处吗?如果有,我应该如何改正?

【问题讨论】:

    标签: ios swift error-handling uiwebview


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-26
      • 1970-01-01
      • 2019-01-27
      • 1970-01-01
      • 2016-07-12
      • 1970-01-01
      • 2018-06-03
      • 1970-01-01
      相关资源
      最近更新 更多