Search code examples
iosxamarin.iosxamarinpspdfkit

How to show annotation toolbar in PSPDFKIT on viewcontroller launch using Xamarin iOS


I am using PSPDFKit and Xamarin iOS. I would like to have the annotation toolbar automatically show when the ViewController that subclasses PSPDFViewController is shown.

Currently I have:

public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();
            AnnotationButtonItem.FlexibleAnnotationToolbar.ShowToolbar (true, new PSPDFFlexibleToolbarFinishedHandler (((bool finished) => {
            })));
        }

Unfortunately nothing is happening. Anyone have experience getting the toolbar to automatically show?


Solution

  • You can either do:

    myPSPDFViewController.AnnotationButtonItem.Action(myPSPDFViewController.AnnotationButtonItem)
    

    Which feels a bit of a fudge. Or you can create your own PSPDFFlexibleAnnotationToolbar, set it as the toolbar on a PSPDFFlexibleAnnotationToolbarContainer, add that container to your view hierarchy and call tooolbar.Show(true, ...)