0

i subclassed QLPreviewController and used

[[self navigationItem] setRightBarButtonItem:nil];

but the navigationItem is only removed in iOS 5, not iOS6

amdstorm
  • 66
  • 6

2 Answers2

0

i managed to do it by creating a timer to check for the navigation item and remove it

Here is the code:

[self inspectSubviewsForView:self.view];

- (void)inspectSubviewsForView:(UIView *)view
{
    for (UIView *subview in view.subviews)
    {
        NSLog(@"class detected %@",[subview description]);
        if ([subview isKindOfClass:[UINavigationBar class]])
        {
            UINavigationBar *bar = (UINavigationBar *)subview;
            if ([[bar items] count] > 0)
            {
                UINavigationItem *navItem = [[bar items] objectAtIndex:0];
                [navItem setRightBarButtonItem:nil];
                {
                }

                if ([subview isKindOfClass:[UIView class]] && [[subview subviews] count] > 0)
                {
                    [self inspectSubviewsForView:subview];
                }
            }
        }
        [self inspectSubviewsForView:subview];
    }
}
amdstorm
  • 66
  • 6
0
Simple solution for this is add one dummy view to current viewController and Add QLPreviewController.view to dummy view . 

 previewController = [[QLPreviewController alloc] init];
 previewController.dataSource = self;
 previewController.delegate = self;
 previewController.currentPreviewItemIndex = 0;

[self.ContentView addSubview:previewController.view];



- (IBAction)removeQPView:(id)sender {

    [previewController.view removeFromSuperview];
}