Reputation: 201
i created a Ios app for reading pdf documents following Apple pdf zooming
https://developer.apple.com/library/ios/samplecode/zoomingpdfviewer/Introduction/Intro.html
but , i don't know how to zoom pdf pages at specific coordinate automatically ,
i mean when my did load method the pdf page zoomed at specific coordinate(x, y) such as : (10, 20)
some body help me ? please !
thank !
Upvotes: 0
Views: 445
Reputation: 25692
From Apple's Sample Code of Zooming PDF Viewer
UIScrollView has the API to do that
[yourScrollView zoomToRect:CGRectMake(X, Y, Width, Height) animated:YES];
Basically if you want to see the animation on your changes then you can put your code in View did Appear method.
#import "ZoomingPDFViewerViewController.h"
#import "PDFScrollView.h"
#import <QuartzCore/QuartzCore.h>
@implementation ZoomingPDFViewerViewController
- (void)viewDidLoad
{
[super viewDidLoad];
/*
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);
}
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
// 1. Get the Scroll View
UIScrollView *scrollView = (UIScrollView*)self.view;
// 2. Zoom to specified rect
[scrollView zoomToRect:CGRectMake(X, Y, Width, Height) animated:YES];
}
Upvotes: 1