Well, i've got good news and bad news.
The good news is i've figured out why this isn't working. In iOS6 the QLPreviewController's navigationItem no longer has a navigationBar:
(lldb) po [[self navigationItem] navigationBar];
(id) $2 = 0x00000000 <nil>
The navigation bar is now located deep within the view hierarchy of the QLPreviewControllersView:
QLPreviewViewController.view->UIView->UIView->QLRemotePreviewContentController->navBar->navItem->rightBarButtonItems.
You can use the below method to find the navigationItem that you're looking for:
- (void)inspectSubviewsForView:(UIView *)view
{
for (UIView *subview in view.subviews)
{
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];
}
}
}
Simply pass [self view] to that method and it will loop until it finds the tab bar in question. You can then remove or add your own.
The bad news is of course that you are accessing private APIs and use of this will likely get your app rejected by the app store. It is however the only answer i've seen on this. Would love to see if there is a non-private way to do this but given the way it's set up, it seems unlikely.
Also, this method will only work if it is called after the bar is already in position. The best place to call this from is the 'viewDidAppear' but it doesn't work 100% of the time.