我需要向QLPreviewController隐藏共享按钮按钮
这是在新视图中显示PDF (例如)的原始代码
var previewItem = NSURL()
func preview(_command: CDVInvokedUrlCommand){
self.previewItem = fileLocationURL! as NSURL
let previewController = QLPreviewController();
previewController.dataSource = self;
self.viewController?.present(previewController, animated: true, completion: nil);
}extension PreviewAnyFile: QLPreviewControllerDataSource {
func numberOfPreviewItems(in controller: QLPreviewController) -> Int {
return 1
}
func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
return self.previewItem as QLPreviewItem
}
}

我尝试了这段代码(将QLPreviewController超类为QLSPreviewController ),但share按钮仍然存在
class QLSPreviewController : QLPreviewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(true )
//This hides the share item
if let add = self.children.first as? UINavigationController {
if let layoutContainerView = add.view.subviews[1] as? UINavigationBar {
layoutContainerView.subviews[2].subviews[1].isHidden = true
}
}
}
}发布于 2019-11-26 17:53:23
基于几个合理安全的假设:
从UIViewController
您应该能够删除UBarButtonItem
在ViewDidLoad内部:
navigationItem.rightBarButtonItems = []如果需要,也可以从类的外部访问:
myPDFViewController.navigationItem.rightBarButtonItems = []https://stackoverflow.com/questions/58998700
复制相似问题