Skip to content

Repository files navigation

WebKitPlus

Carthage compatible

A support library for WKWebView.

Requirements

  • iOS 12.0 later

Usage

WKUIDelegatePlus

WKUIDelegatePlus has standard implements(Present alerts from JavaScript) for WKUIDelegate.

overridepublicfunc viewDidLoad(){
super.viewDidLoad()
UIDelegate =WKUIDelegatePlus(self)
webView.UIDelegate = UIDelegate
}

WebViewObserver

It is funtastic that WKWebView has key-value observing compliant properties, but KVO is so ugly. WebViewObserver makes observable it by closure.

lazy varobserver:WebViewObserver=WebViewObserver(self.webView)overridepublicfunc viewDidLoad(){
super.viewDidLoad()
observer.onTitleChanged ={[weak self]inself?.title = $0 }
observer.onProgressChanged ={[weak self]inself?.progressbar.progress = $0 }}

Authentication in navigation

Use UIAlertController (for: completion :) to input informations of authentication.

/// in `WKNavigationDelegate` object
func webView(_ webView:WKWebView, didReceive challenge:URLAuthenticationChallenge, completionHandler:@escaping(URLSession.AuthChallengeDisposition,URLCredential?)->Void){guardlet alert =UIAlertController(for: challenge, completion: completionHandler)else{
// Should call `completionHandler` if `alertForAuthentication` return `.None`.
completionHandler(.performDefaultHandling,nil)return}present(alert, animated:true, completion:nil)}

ZenWebViewController

ZenWebViewController is a Simple View Controller contains WKWebView. You can implement simple web browser with it.

Author

@yashigani

License

WebKitPlus is available under the MIT license. See the LICENSE file for more info.

About

A support library for WKWebView.

Resources

Stars

56 stars

Watchers

6 watching

Forks

Releases

Packages

Contributors

Languages