3

I'm working on a project that displays a PDF using QLPreviewController from two different views. One view pushes the QLPreviewController onto the base navigation, and the other one is a modal view that brings the QLPreviewController up in modal.

I had issues when I initially set this up with the push including setting the nav bar opacity and the nav bar blocking my PDF. I was able to solve both issues by subclassing the QLPreviewController:

#import "CustomPreviewController.h"

@interface CustomPreviewController ()

@end

@implementation CustomPreviewController

-(id) init {
    self = [super init];
    if(self){
        // init
    } return self;
}

- (void) viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    // set translucency of navigation bar
    self.navigationController.navigationBar.translucent = NO;
    // nav bar does not overlap content
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.automaticallyAdjustsScrollViewInsets = YES;
}

@end

However, now I need to view the same PDF from a different flow in the app. For this design I need a modal pop up to a UITableView, then either a push or a modal from that tableview to a PDF in the QLPreviewController. When I use the same push animation I get a delay and fracturing of the animation and a glitchy toolbar at the top. (See this post here). When I use a modal it animates smoothly but my UINavigationBar is hiding the top of the PDF and covering the page number. Similar nav bar symptoms to the push issues in the linked post. I have tried the solution proposed there, as well as attempting to hide the nav bar of the initial modal and the preview controller, to no avail.

This might be an Apple bug/issue but if anyone has discovered a usable workaround any suggestions would be welcome.

Community
  • 1
  • 1
robotsquidward
  • 163
  • 2
  • 16

0 Answers0