我正在尝试UIMenuItem为我的PDFView
这是我在示例 Xcode 项目中所做的
#import <PDFKit/PDFKit.h>
#import <objc/runtime.h>
#import "ViewController.h"
@interface ViewController ()
@property(nonatomic) PDFDocument *document;
@property(nonatomic) PDFView *pdfView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
NSURL *pdfPath = [[NSBundle mainBundle] URLForResource:@"pdf" withExtension:@"pdf"];
_document = [[PDFDocument alloc] initWithURL:pdfPath];
_pdfView = [[PDFView alloc] initWithFrame:CGRectZero];
_pdfView.document = _document;
[self.view addSubview:_pdfView];
_pdfView.translatesAutoresizingMaskIntoConstraints = NO;
[_pdfView.topAnchor constraintEqualToAnchor:self.view.topAnchor].active = YES;
[_pdfView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor].active = YES;
[_pdfView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor].active = YES;
[_pdfView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor].active = YES; …Run Code Online (Sandbox Code Playgroud)