I am subclassing QLPreviewController in my application and using the following code.
QLPreviewControllerSubClass* preview = [[QLPreviewControllerSubClass all
I have found a solution to disable (not hide) therightBarButtonItem
in QLPreviewController
The solution works fine for me in iOS8 and iOS9
You simply need to subclass QLPreviewController
and override the following methods, then use your subclass instead of the original QLPreviewController
- (void)viewDidLoad {
[super viewDidLoad];
// When coming back from background we make sure the share button on the rightbBarButtonItem is disabled
__weak typeof(self) weakSelf = self;
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
weakSelf.navigationItem.rightBarButtonItem.enabled = NO;
}];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.navigationItem.rightBarButtonItem.enabled = NO; // Disable the share button
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.navigationItem.rightBarButtonItem.enabled = NO; // Disable the share button
}