Latest 0.3.1
Homepage https://github.com/yashigani/WebKitPlus
License MIT
Platforms ios 8.0
Frameworks WebKit
Authors

Carthage compatible

A support library for WKWebView.

Requirements

  • iOS 8.0 later

Usage

WKUIDelegatePlus

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

override public func 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 var observer: WebViewObserver = WebViewObserver(self.webView)
override public func viewDidLoad() {
    super.viewDidLoad()
    observer.onTitleChanged = { [weak self] in self?.title = $0 }
    observer.onProgressChanged = { [weak self] in self?.progressbar.progress = $0 }
}

Authentication in navigation

alertForAuthentication function create UIAlertController for input informations of authenticcation.

/// in `WKWebNavigationDelegate` object
func webView(webView: WKWebView, didReceiveAuthenticationChallenge challenge: NSURLAuthenticationChallenge, completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Void) {
    guard let alert = alertForAuthentication(challenge, completionHandler) else {
        // Should call `completionHandler` if `alertForAuthentication` return `.None`.
        completionHandler(.PerformDefaultHandling, nil)
        return
    }
    presentViewController(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.

Latest podspec

{
    "name": "WebKitPlus",
    "version": "0.3.1",
    "summary": "A support library for WKWebView.",
    "description": "WebKitPlus is a support library for WKWebView in iOS Apps.",
    "authors": {
        "yashigani": "[email protected]"
    },
    "homepage": "https://github.com/yashigani/WebKitPlus",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "platforms": {
        "ios": "8.0"
    },
    "frameworks": "WebKit",
    "source": {
        "git": "https://github.com/yashigani/WebKitPlus.git",
        "tag": "0.3.1"
    },
    "source_files": "WebKitPlus/*.{swift,h}",
    "resource_bundles": {
        "WebKitPlus": [
            "WebKitPlus/*.lproj"
        ]
    },
    "pod_target_xcconfig": {
        "APPLICATION_EXTENSION_API_ONLY": "YES"
    },
    "swift_version": "4.1",
    "cocoapods_version": ">= 1.4.0"
}

Pin It on Pinterest

Share This