Hide right button n QLPreviewController?

后端 未结 8 1413
-上瘾入骨i
-上瘾入骨i 2021-01-17 01:35

I am subclassing QLPreviewController in my application and using the following code.

QLPreviewControllerSubClass* preview = [[QLPreviewControllerSubClass all         


        
8条回答
  •  有刺的猬
    2021-01-17 02:00

    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
    }
    

提交回复
热议问题