diff --git a/CEMKit-Swift.xcodeproj/project.xcworkspace/xcuserdata/cem.xcuserdatad/UserInterfaceState.xcuserstate b/CEMKit-Swift.xcodeproj/project.xcworkspace/xcuserdata/cem.xcuserdatad/UserInterfaceState.xcuserstate index a44da98..d362581 100644 Binary files a/CEMKit-Swift.xcodeproj/project.xcworkspace/xcuserdata/cem.xcuserdatad/UserInterfaceState.xcuserstate and b/CEMKit-Swift.xcodeproj/project.xcworkspace/xcuserdata/cem.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/CEMKit-Swift/CEMKit.swift b/CEMKit-Swift/CEMKit.swift index 0221f76..a6cd6e0 100644 --- a/CEMKit-Swift/CEMKit.swift +++ b/CEMKit-Swift/CEMKit.swift @@ -540,3 +540,45 @@ class BlockButton: UIButton { +// MARK: - UIWebView + +class BlockWebView: UIWebView, UIWebViewDelegate { + + var didStartLoad: ((NSURLRequest) -> ())? + var didFinishLoad: ((NSURLRequest) -> ())? + var didFailLoad: ((NSURLRequest, NSError) -> ())? + + var shouldStartLoadingRequest: ((NSURLRequest) -> (Bool))? + + override init(frame: CGRect) { + super.init(frame: frame) + delegate = self + } + + required init(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + + func webViewDidStartLoad(webView: UIWebView) { + didStartLoad? (webView.request!) + } + + func webViewDidFinishLoad(webView: UIWebView) { + didFinishLoad? (webView.request!) + } + + func webView(webView: UIWebView, didFailLoadWithError error: NSError) { + didFailLoad? (webView.request!, error) + } + + func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool { + if let should = shouldStartLoadingRequest { + return should (request) + } else { + return true + } + } + +} +