gpt4 book ai didi

uimenucontroller - PDFKit 错误,需要禁用 UIMenuItems

转载 作者:行者123 更新时间:2023-12-04 17:37:14 29 4
gpt4 key购买 nike

我正在尝试禁用 PDFKit 中的 UIMenuItems。我已经实现了

override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
return false
}

但是 MenuItems CopySelect All 仍然有效。我想禁用它们的主要原因是 全选 在较大的 pdf 文档上会导致致命的内存错误。

malloc: can't allocate region

我已经提交了错误报告,但同时我需要禁用菜单项。

注意:如果 pdfDocument.string 足够大,以下任何调用都会导致崩溃。

  1. pdfView.selectAll()
  2. UIMenuController.selectAll
  3. 让字符串 = pdfDocument.string

最佳答案

我需要覆盖实际 PDFView 上的 canPerformAction。我是在我的 VC 中做的。

class MyPDFView: PDFView {
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
return false
}
}

关于uimenucontroller - PDFKit 错误,需要禁用 UIMenuItems,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56153830/

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