swift - WKWebView无法拖动Element

标签 swift macos webview uiwebview wkwebview

我有一个使用 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/

相关文章:

ios - 向按钮添加条件(Swift)

ios - Swift-检测点击 NSMutableAttributedString

android - WebView setJavaScriptEnabled 和 JavaScript 现场

android - Android 中的多个 webview

android - 如何通过 React Native 在 Android WebView 中隐藏滚动条

swift - 如何使用 Share Extensions Swift 共享包含标记的笔记

ios - Swift 3 - 比较两个日期时对 < 运算符的使用不明确

C segfault 11 以及文件 i/o 可能出现的其他错误

macos - GCC运行汇编程序mac?

linux - macOS 无法删除带有 sunlnk 标志的文件夹