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:shouldShowMenuItems:atSuggestedTargetRect:forAnnotations:inRect:onPageView: method from PSPDFViewControllerDelegate:

Copy
1
2
3
func pdfViewController(_ pdfController: PSPDFViewController, shouldShow menuItems: [PSPDFMenuItem], atSuggestedTargetRect rect: CGRect, for annotations: [PSPDFAnnotation]?, in annotationRect: CGRect, on pageView: PSPDFPageView) -> [PSPDFMenuItem] {
  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 to be 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 PSPDFResizableView and always returning a false value from the -allowResizing property getter.

1
2
3
4
5
6
class NonResizableView: PSPDFResizableView {
  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