我有一个正在 Webkit 中加载的网络应用程序,截至目前,当用户没有互联网连接时,会显示一条错误消息和此代码。我想让它显示一个全新的 View ,而不仅仅是一条错误消息。
func webView(webView: WKWebView!, didFailProvisionalNavigation navigation: WKNavigation!, withError error: NSError!) {
let alert = UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "Ok", style: .Default, handler: nil))
presentViewController(alert, animated: true, completion: nil)
}
最佳答案
您可以创建一个新的 UIView 并将其添加到当前的 ViewController 中:
var errorView = UIView(frame: CGRectMake(100, 100, 100, 100))
self.view.addSubview(errorView)
关于xcode - 当用户在 webkit 中没有互联网连接时加载新 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28682382/