Hello,
I am developing a Mac application via Mac Catalyst and encountering an issue with WKWebView. Specifically, I'm loading a webpage (e.g., https://translate.google.com) in WKWebView, but when I press the copy button on the page, the content doesn't actually copy to the clipboard.
I've attempted modifying the UserAgent without any success. Here is the relevant part of my code:
override func viewDidLoad() {
super.viewDidLoad()
let config = WKWebViewConfiguration()
config.preferences = WKPreferences()
config.defaultWebpagePreferences.preferredContentMode = .desktop
let webView = WKWebView(frame: .zero, configuration: config)
webView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(webView)
webView.scrollView.showsVerticalScrollIndicator = false
webView.backgroundColor = UIColor.white
webView.scrollView.backgroundColor = UIColor.white
webView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
webView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
webView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
webView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
if let url = URL(string: "https://translate.google.com") {
let req = URLRequest(url: url)
webView.load(req)
}
}