Bunun eski bir soru olduğunu biliyorum, ancak bir çözüm aramak için çok fazla zaman harcadım ve işe yarayan bir şey buldum.
Yani, benimle aynı şeyi arayanlar için. İşte benim çözümüm.
Kodlar amaç-c ama
Önce QLPreviewController alt sınıfını oluşturup alt sınıfta aşağıdaki yöntemleri
Edit geçersiz Swift
için
Swift basit dönüşüm olabilir it'l:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationItem.rightBarButtonItem = nil
//For ipads the share button becomes a rightBarButtonItem
self.navigationController?.toolbar?.isHidden = true
//This hides the share item
self.navigationController?.toolbar?.addObserver(self, forKeyPath: "hidden", options: NSKeyValueObservingOptionPrior, context: nil)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.navigationController?.toolbar?.removeObserver(self, forKeyPath: "hidden")
}
override func observeValue(forKeyPath keyPath: String, ofObject object: Any, change: [AnyHashable: Any], context: UnsafeMutableRawPointer) {
var isToolBarHidden: Bool? = self.navigationController?.toolbar?.isHidden
// If the ToolBar is not hidden
if isToolBarHidden == nil {
DispatchQueue.main.async(execute: {() -> Void in
self.navigationController?.toolbar?.isHidden = true
})
}
}
self.navigationController?.pushViewController(qlPreviewController, animated: true)
Objective-C:
-(void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[[self.navigationController toolbar] removeObserver:self forKeyPath:@"hidden"];
}
viewWillDisappear
Ve gözlemci yöntemine Observer kaldırın: Gerekli Tekli musluk görüntü gezinme çubuğu ve araç çubuğunu gizlemek için zaman, paylaşma düğmesi musluğu tekrar görünür hale çünkü.
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
BOOL isToolBarHidden = [self.navigationController toolbar].hidden;
// If the ToolBar is not hidden
if (!isToolBarHidden) {
dispatch_async(dispatch_get_main_queue(), ^{
[[self.navigationController toolbar] setHidden:YES];
});
}
}
Ve PreviewController
[self.navigationController pushViewController:qlPreviewController animated:YES];
NavigationController
mevcut senden itilmiş zorundadır Ve ayrıca biz yerine QLPreviewController alt sınıfını kullanmak zorunda.
Belki bu yardımcı olabilir: http://stackoverflow.com/questions/22953117/hide-right-button-n-qlpreviewcontroller? – Terry
benim için iyi çalışıyor https://stackoverflow.com/a/45344701/1603380 – Buntylm