gpt4 book ai didi

swift - WKWebView无法拖动Element

转载 作者:行者123 更新时间:2023-11-30 10:33:01 24 4
gpt4 key购买 nike

我有一个使用 WKWebView 的 macOS 应用程序。我以编程方式克隆该 WebView 以获取另一个 View 。但是当我尝试将新约束设置为等于主 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 或主视图相关也并不重要。

最佳答案

好吧。我找出了问题所在:WebView – 即使 isHidden = true “在技术上分层在原始 WebView 之上”——因此,当切换事件 WebView 时,我需要将 View 置于前面。

这与约束本身无关。

关于swift - WKWebView无法拖动Element,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58697209/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com