Customizing the Annotation Table View Controller

PSPDFKit allows you to customize the annotation table view controller. Here are the two approaches to customizing settings in the PSPDFAnnotationTableViewController:

  1. Subclass the view controller, and then register your subclass, overrideClass:withClass:, in the PSPDFConfigurationBuilder. Configure any properties in the init method of the subclass.
  1. Use the shouldShowController: delegate.

This is a bit tedious, since the annotation controller is packed inside a container view controller unless all other view controller options are disabled in the outline bar button:

Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
static id PSCControllerForClass(id theController, Class klass) {
    if ([theController isKindOfClass:klass]) {
        return theController;
    }else if ([theController isKindOfClass:UINavigationController.class]) {
        return PSCControllerForClass(((UINavigationController *)theController).topViewController, klass);
    }else if ([theController isKindOfClass:PSPDFContainerViewController.class]) {
        for (UIViewController *contained in ((PSPDFContainerViewController *)theController).viewControllers) {
            if (PSCControllerForClass(contained, klass)) return PSCControllerForClass(contained, klass);
        }
    }
    return nil;
}

- (BOOL)pdfViewController:(PSPDFViewController *)pdfController shouldShowController:(UIViewController *)controller options:(nullable NSDictionary<NSString *, id> *)options animated:(BOOL)animated {
    PSCLog(@"shouldShowViewController: %@ animated: %d.", controller, animated);

    PSPDFAnnotationTableViewController *annotCtrl = PSCControllerForClass(controller, PSPDFAnnotationTableViewController.class);
    annotCtrl.showDeleteAllOption = NO;

    return YES;
}

Please take a look at PSCKioskPDFViewController.m in PSPDFCatalog for more details.