#ios #swift #webkit
Вопрос:
Я также добавил разрешения для микрофона и библиотеки фотографий камеры, но не смог получить выбранные изображения на веб-странице. Он отлично работает в Safari и Chrome.
Here is the code to initialize the webview with the url etc etc.
import UIKit
import WebKit
import CircularRevealKit
class MainVC: UIViewController, WKNavigationDelegate, WKUIDelegate {
@IBOutlet weak var revealView: UIView!
@IBOutlet weak var loadingView: UIView!
@IBOutlet weak var mainWebKit: WKWebView!
var newWebviewPopupWindow: WKWebView?
override func viewDidLoad() {
super.viewDidLoad()
let url = URL(string: "https://wequestion.pk/")
mainWebKit.load(URLRequest(url: url!))
mainWebKit.scrollView.contentInsetAdjustmentBehavior = .never;
mainWebKit.navigationDelegate = self
self.mainWebKit.uiDelegate = self
// Do any additional setup after loading the view.
}
func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? {
let userAgent = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36 Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10"
newWebviewPopupWindow = WKWebView(frame: view.bounds, configuration: configuration)
newWebviewPopupWindow!.autoresizingMask = [.flexibleWidth, .flexibleHeight]
newWebviewPopupWindow!.navigationDelegate = self
newWebviewPopupWindow!.uiDelegate = self
newWebviewPopupWindow!.customUserAgent = userAgent
view.addSubview(newWebviewPopupWindow!)
return newWebviewPopupWindow!
}
func webViewDidClose(_ webView: WKWebView) {
webView.removeFromSuperview()
newWebviewPopupWindow = nil
}
}