I am using the following github project
https://github.com/jackhumphries/UIPageViewController-PDF
the problem is loading pdf, and the page freeze effect works, but I cannot increase or decrease my pdf document which is loaded. I also try to debug, and then why it doesnβt work, but I canβt find a solution, and I checked the PDFScrollView delegation methods, they are all implemented, but these methods do not call when I try to zoom in / out.
These methods are:
- (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; }
And I have this code:
-(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; }
and I want to implement this code below the code above
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);
source share