WKWebView无法拖动元素

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

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

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

更新

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

sunyirui 回答:WKWebView无法拖动元素

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

它与约束本身无关。

本文链接:https://www.f2er.com/3165328.html

大家都在问