问题描述
我们如何为WKWebView中的链接设置自定义上下文菜单?
您可以通过以下操作在项目上设置上下文菜单:
let interaction = UIContextMenuInteraction(delegate: self)
someItem.addInteraction(interaction)
并添加UIContextMenuInteractionDelegate
委托:
func contextMenuInteraction(_ interaction: UIContextMenuInteraction,configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? {
let configuration = UIContextMenuConfiguration(identifier: nil,previewProvider: nil) { (_) -> UIMenu? in
let shareAction = UIAction(title: "Send to Friend",image: UIImage(systemName: "square.and.arrow.up")) { _ in
// Pressed
}
let menu = UIMenu(title: "",children: [shareAction])
return menu
}
return configuration
}
当用户按住WKWebView中的链接时,如何使用自定义上下文菜单?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)