2

I am using Quicklook to show some PDF files, the user needs to just see the file and then click done. the default UI gives more options like the copy or print email. Also the UI shows arrows next to the done button that can navigate to other files available. Both of which I need removed ( hidden ). Now I browsed around and most posts talk about subclassing QLPreviewController, and customizing the new class. So I am doing this in the following manner :

  @interface MyQLViewer : QLPreviewController <QLPreviewControllerDataSource, QLPreviewControllerDelegate> {

}

and in the .m file

- (void)viewWillAppear:(BOOL)animated
{
   [super viewWillAppear:animated];
   [[self navigationItem] setRightBarButtonItem:nil];
}

now in my own project I have a MyQLViewer property that I [MyQLViewer alloc] init] in the viewdidload event of the xib.

This is not working. what am I missing?

Thanks.

enter image description here

Huang
  • 1,355
  • 2
  • 11
  • 28

1 Answers1

1

As far as I know is no longer possible to disable right button with iOs 6 you can read more about it here: http://www.cimgf.com/2012/07/11/a-better-fullscreen-asset-viewer-with-quicklook/

update: this workaround works for me. called with a delay cause it was re-added if document load requires few instant

- (void)removeActionButton  {

    if(removeShareCounter > 13){
        [removeButtonTimer invalidate];

    }
    else{
        //iOs doesn't support setRightBarButtonItem to nil
        if ([self iOsEqual:6]) {
            [self inspectSubviewsForView:self.view];
        }
        else{
            [self.navigationItem setRightBarButtonItem:nil animated:NO];
        }
        removeShareCounter++;
    }
}

- (void)inspectSubviewsForView:(UIView *)view
{
    if(view != NULL){
        if ([view isKindOfClass:[UINavigationBar class]])
        {
            UINavigationBar *bar = (UINavigationBar *)view;
            if ([[bar items] count] > 0)
            {
                UINavigationItem *navItem = [[bar items] objectAtIndex:0];
                [self performSelectorOnMainThread:@selector(removeShareButton:) withObject:navItem waitUntilDone:YES];
            }
        }
        else{
            for (UIView *subView in view.subviews) {
                [self inspectSubviewsForView:subView];
            }    
        }
    }
}

-(void)removeShareButton: (UINavigationItem *)navItem{
    [navItem setRightBarButtonItems:nil animated:NO];
}
Adel
  • 91
  • 4