WKWebView无法拖动元素

问题描述 投票:0回答:1

我有一个使用WKWebView的macOS应用。我以编程方式克隆该WebView以获得另一个视图。但是当我尝试将新约束设置为等于主WebView时,像这样

NSLayoutConstraint(item: copiedWebView, attribute: .centerY, relatedBy: .equal, toItem: self.webView, attribute: .centerY, multiplier: 1.0, constant: 0.0).isActive = true
NSLayoutConstraint(item: copiedWebView, attribute: .height, relatedBy: .equal, toItem: self.webView, attribute: .height, multiplier: 1.0, constant: 0.0).isActive = true
NSLayoutConstraint(item: copiedWebView, attribute: .centerX, relatedBy: .equal, toItem: self.webView, attribute: .centerX, multiplier: 1.0, constant: 0.0).isActive = true
NSLayoutConstraint(item: copiedWebView, attribute: .width, relatedBy: .equal, toItem: self.webView, attribute: .width, multiplier: 1.0, constant: 0.0).isActive = true

两个WebView都不能拖放某些东西。

更新

奇怪...当我设置高度限制...active = false时,拖放有效。约束是否与原始webView或主视图有关也无关紧要。

swift macos webview uiwebview wkwebview
1个回答
0
投票

好的。我弄清楚了问题所在:WebView –即使isHidden = true在技术上位于原始WebView之上–因此,在切换活动WebView时,我需要将视图置于最前面。

与约束本身无关。

© www.soinside.com 2019 - 2024. All rights reserved.