Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yashigani/WebKitPlus
A support library for WKWebView.
https://github.com/yashigani/WebKitPlus
Last synced: 13 days ago
JSON representation
A support library for WKWebView.
- Host: GitHub
- URL: https://github.com/yashigani/WebKitPlus
- Owner: yashigani
- License: mit
- Created: 2015-03-25T21:16:39.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-07-25T13:06:04.000Z (over 2 years ago)
- Last Synced: 2024-09-21T03:22:08.769Z (about 2 months ago)
- Language: Swift
- Size: 110 KB
- Stars: 58
- Watchers: 7
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
WebKitPlus
==========[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
A support library for WKWebView.
## Requirements
- iOS 12.0 later
## Usage
### WKUIDelegatePlus
`WKUIDelegatePlus` has standard implements(Present alerts from JavaScript) for `WKUIDelegate`.``` swift
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.``` swift
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
Use `UIAlertController (for: completion :)` to input informations of authentication.``` swift
/// in `WKNavigationDelegate` object
func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
guard let 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.