How Can I Block Annotation Editing and Deletion, While Still Allowing for Annotation Manipulation?

The simplest way to achieve what you want is to return an empty array from the pdfViewController(_:shouldShow:atSuggestedTargetRect:for:in:on:) method from PDFViewControllerDelegate:

Copy
1
2
3
func pdfViewController(_ pdfController: PDFViewController, shouldShow menuItems: [MenuItem], atSuggestedTargetRect rect: CGRect, for annotations: [Annotation]?, in annotationRect: CGRect, on pageView: PDFPageView) -> [MenuItem] {
  return []
}
Copy
1
2
3
4
- (NSArray<PSPDFMenuItem *> *)pdfViewController:(PSPDFViewController *)pdfController shouldShowMenuItems:(NSArray<PSPDFMenuItem *> *)menuItems atSuggestedTargetRect:(CGRect)rect forAnnotations:(NSArray<PSPDFAnnotation *> *)annotations inRect:(CGRect)annotationRect onPageView:(PSPDFPageView *)pageView {
  // Return an empty array to avoid showing annotation editing controls.
  return @[];
}

This will prevent the annotation menus from being displayed when an annotation is selected by the user.

The next step is to prevent the selected annotations from being resized. This can be achieved by overriding ResizableView and always returning a false value from the allowResizing property getter.

1
2
3
4
5
6
class NonResizableView: ResizableView {
  override var allowResizing: Bool {
    get { return false }
	set {}
  }
}
1
2
3
4
5
6
7
8
9
10
@interface NonResizableView : PSPDFResizableView
@end

@implementation NonResizableView

- (BOOL)allowResizing {
    return NO;
}

@end