我正在尝试禁用 PDFKit 中的 UIMenuItems。我已经实现了
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
return false
}
但是 MenuItems Copy 和 Select All 仍然有效。我想禁用它们的主要原因是 全选 在较大的 pdf 文档上会导致致命的内存错误。
malloc: can't allocate region
我已经提交了错误报告,但同时我需要禁用菜单项。
注意:如果 pdfDocument.string 足够大,以下任何调用都会导致崩溃。
- pdfView.selectAll()
- UIMenuController.selectAll
- 让字符串 = 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/