如何隐藏 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/