WebView 禁用Drag and Drop
2022-05-13 本文已影响0人
路在脚下了
主要思路是查找webView中的contentView,并从其中的interactions中找到对应的UIDragInteraction,然后删除掉即可;
如需删除drop等其它action,同理;
实例代码如下:
let scrollView = webView.scrollView
let contentView = scrollView.subviews.first(where: { $0.interactions.count > 1 })
guard let dragAction = (contentView?.interactions.compactMap {$0 as? UIDragInteraction}.first) else { return }
contentView?.removeInteraction(dragAction)