我将 QLPreviewController 子类化并使用
[[self navigationItem] setRightBarButtonItem:nil];
但 navigationItem 仅在 iOS 5 中被删除,而不是 iOS6
我将 QLPreviewController 子类化并使用
[[self navigationItem] setRightBarButtonItem:nil];
但 navigationItem 仅在 iOS 5 中被删除,而不是 iOS6
我设法通过创建一个计时器来检查导航项并将其删除来做到这一点
这是代码:
[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];
}
}
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];
}