UIPageViewController-PDF缩放不工作的Xcode?

我正在使用下面的github项目

https://github.com/jackhumphries/UIPageViewController-PDF

问题是PDF正在加载和页面curl效果工作,但我不能放大和缩小我的PDF文件加载我尝试debugging以及为什么它不工作,但我找不到解决scheme,我检查了PDFScrollView委托方法,他们都实现了,但是当我试图放大/缩小时,这些方法并没有调用。

这里是这些方法:

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return self.tiledPDFView; } - (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view { // Remove back tiled view. [self.oldTiledPDFView removeFromSuperview]; // Set the current TiledPDFView to be the old view. self.oldTiledPDFView = self.tiledPDFView; [self addSubview:self.oldTiledPDFView]; } - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale { // Set the new scale factor for the TiledPDFView. _PDFScale *= scale; // Calculate the new frame for the new TiledPDFView. CGRect pageRect = CGPDFPageGetBoxRect(_PDFPage, kCGPDFMediaBox); pageRect.size = CGSizeMake(pageRect.size.width*_PDFScale, pageRect.size.height*_PDFScale); // Create a new TiledPDFView based on new frame and scaling. TiledPDFView *tiledPDFView = [[TiledPDFView alloc] initWithFrame:pageRect scale:_PDFScale]; [tiledPDFView setPage:_PDFPage]; // Add the new TiledPDFView to the PDFScrollView. [self addSubview:tiledPDFView]; self.tiledPDFView = tiledPDFView; } 

我有这个代码:

 -(id)initWithPDFAtPath:(NSString *)path { NSURL *pdfUrl = [NSURL fileURLWithPath:path]; PDFDocument = CGPDFDocumentCreateWithURL((__bridge CFURLRef)pdfUrl); totalPages = (int)CGPDFDocumentGetNumberOfPages(PDFDocument); self = [super initWithNibName:nil bundle:nil]; return self; } 

我想在下面的代码实现这个代码

 /* Open the PDF document, extract the first page, and pass the page to the PDF scroll view. */ NSURL *pdfURL = [[NSBundle mainBundle] URLForResource:@"TestPage" withExtension:@"pdf"]; CGPDFDocumentRef PDFDocument = CGPDFDocumentCreateWithURL((__bridge CFURLRef)pdfURL); CGPDFPageRef PDFPage = CGPDFDocumentGetPage(PDFDocument, 1); [(PDFScrollView *)self.view setPDFPage:PDFPage]; CGPDFDocumentRelease(PDFDocument); 

将此方法添加到PDFScrollView:

 - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.decelerationRate = UIScrollViewDecelerationRateFast; self.delegate = self; self.minimumZoomScale = 1.0; self.maximumZoomScale = 3.0; } return self; } 

并将最后两行添加到scrollViewDidEndZooming

 - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale { .... self.minimumZoomScale = 1.0/scale; self.maximumZoomScale = 3.0*scale; } 

请注意,更改页面仅在页面处于最低缩放级别时才起作用(如在多个阅读器应用程序中发生的情况)。