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 AnnotationTableViewController:

  1. Subclass the view controller, and then register your subclass, overrideClass(_:with:), in the PDFConfigurationBuilder. Configure any properties in the init method of the subclass.

  1. Use the pdfViewController(_:shouldShow:options:animated:) 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:

static func PSCContainedControllerOfClass<U: UIViewController, T>(container controller: U, klass: T.Type) -> T? {
    if let vc = controller as? T {
        return vc
    } else if let topVC = (controller as? UINavigationController)?.topViewController {
        return PSCContainedControllerOfClass(container: topVC, klass: klass)
    } else if let containerVC = controller as? ContainerViewController {
        for viewController in containerVC.viewControllers {
            if let containedVC = PSCContainedControllerOfClass(container: viewController, klass: klass) {
                return containedVC
    return nil

func pdfViewController(_ pdfController: PDFViewController, shouldShow controller: UIViewController, options: [String : Any]? = nil, animated: Bool) -> Bool {
    let annotationController = PSCContainedControllerOfClass(container: controller, klass: AnnotationTableViewController.self)
    annotationController?.showDeleteAllOption = false

    // Only show ink, highlight, and stamp annotations in the annotation list.
    annotationController?.visibleAnnotationTypes = [.ink, .highlight, .stamp]

    return true
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;

    // Only show ink, highlight, and stamp annotations in the annotation list.
    annotCtrl.visibleAnnotationTypes = [NSSet<PSPDFAnnotationString> setWithArray:@[PSPDFAnnotationStringInk, PSPDFAnnotationStringHighlight, PSPDFAnnotationStringStamp]];

    return YES;

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