Created
June 2, 2020 02:25
-
-
Save pay-napster-x/6fd5b4b47496dffc21a14a4be009850b to your computer and use it in GitHub Desktop.
WKWebView Configure.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func configWebView() { | |
guard webView == nil else { return } | |
let config = WKWebViewConfiguration() | |
config.userContentController.add(WebKitLeakAvoider(delegate: self), name: CashfeedWebUtil.JavaScriptMessage.getPost) | |
config.userContentController.add(WebKitLeakAvoider(delegate: self), name: CashfeedWebUtil.JavaScriptMessage.getUserInfo) | |
config.userContentController.add(WebKitLeakAvoider(delegate: self), name: CashfeedWebUtil.JavaScriptMessage.getDeviceInfo) | |
config.setURLSchemeHandler(UploadWKSchemeHandler(), forURLScheme: PreviewViewModel.uploadURLScheme) | |
config.allowsInlineMediaPlayback = true | |
config.mediaTypesRequiringUserActionForPlayback = .audio | |
webView = WKWebView(frame: view.bounds, configuration: config) | |
webView.scrollView.bounces = false | |
webView.scrollView.alwaysBounceVertical = false | |
webView.translatesAutoresizingMaskIntoConstraints = false | |
webView.isOpaque = false | |
webView.backgroundColor = .white | |
view.addSubview(webView) | |
NSLayoutConstraint | |
.activate([webView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), | |
webView.leadingAnchor.constraint(equalTo: view.leadingAnchor), | |
webView.trailingAnchor.constraint(equalTo: view.trailingAnchor), | |
webView.bottomAnchor.constraint(equalTo: view.bottomAnchor)]) | |
previewViewModel.webRequest() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment