我理解,对于iOS UIWebView
,我可以实现UIWebViewDelegate
,然后访问所需的方法。
但是对于自定义浏览器SVWebViewController,我很困惑如何实现委托方法,因为我尝试在上面实现UIWebViewDelegate
并且它不起作用(“加载”消息未显示在全部)。
class TableInfo: UITableViewController, MWFeedParserDelegate, ENSideMenuDelegate,UIWebViewDelegate{
var allowLoad = true
func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
println("Load")
return allowLoad
}
func webViewDidFinishLoad(webView: UIWebView) {
allowLoad = false
}
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if hasInternet {
let item = self.items[indexPath.row] as MWFeedItem
let URL = NSURL(string: item.link)
let con = SVWebViewController(URL: URL)
self.navigationController?.pushViewController(con, animated: true)
}
}