ios6 - QLPreviewController在ios6中隐藏打印按钮

标签 ios6 qlpreviewcontroller

如何隐藏 QLPreviewController 中的打印按钮

IOS5 中,此代码有效

QLPreviewController *previewController = [[QLPreviewController alloc] init];
previewController.dataSource = self;
previewController.delegate = self;
previewController.currentPreviewItemIndex = _fileidx;
[[self navigationController] pushViewController:previewController animated:YES];
[previewController.navigationItem setRightBarButtonItem:nil];

但在 IOS6 中,则不然。

最佳答案

我设法通过创建一个计时器来检查导航项并将其删除来做到这一点

myTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
             target:self
             selector:@selector(hideRightButton:)
             userInfo:nil
             repeats:YES];
- (void)hideRightButton:(NSTimer *)timer {
    [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];
    }
}

关于ios6 - QLPreviewController在ios6中隐藏打印按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13083546/

相关文章:

iphone - 单个约束的自动布局约束错误

iphone - 如何在 iOS 应用程序中添加文本区域

Facebook SDK 3.1 presentShareDialogModally 失败

ios - QLPreviewController 有时不显示文档

ios - QLPreviewController播放视频

ios - 多声道音频 iOS(需要 4 个同时输入)

ios - UIView 似乎不记得它的标签

ios - 导航栏与 QLPreviewController 中的状态栏重叠

objective-c - iOS 6.0 Quicklook QLPreviewController 错误 : "Cannot find preview item for loaded proxy"

iphone - 表格 View 单元格中的 PDF 预览