我打這個,這兩天我沒有找到有關CGPDF任何適當的文件。我嘗試了所有可能的方式,但我失敗了。這是我想要做的。我有一個PDF顯示,我在UIWebView中顯示它。我使用pdf所在的路徑(NSURL)創建了CORE GRAPHICS PDF文檔參考。我在它上面創建了一個UIView,並處理了一個觸摸事件。當PDF加載和用戶點擊視圖我希望頁面滾動到特定頁面。我知道這可以通過計算頁面高度和寬度來完成。我想知道在CGPDF中是否有方法傳遞頁碼,並滾動到相關頁面。以下是我的代碼滾動到具體頁面,使用CGPDF
- (void)viewDidLoad
{
[super viewDidLoad];
// set the pdfPafeHeight to -1 so it gets calculated.
self.pdfPageHeight = -1;
// set the delegate of the UIWebView's underlying UIScrollView to self.
self.webView.scrollView.delegate = self;
// create an NSURLRequest to load the PDF file included with the project
_filePath = [[NSBundle mainBundle] pathForResource:@"Sample" ofType:@"pdf"];
_url = [NSURL fileURLWithPath:_filePath isDirectory:NO];
_urlRequest = [NSURLRequest requestWithURL:_url];
// create a Core Graphics PDF Document ref using the same NSURL
_pdf = CGPDFDocumentCreateWithURL((CFURLRef) _url);
// use CGPDFDocumentGetNumberOfPages to get the number of pages in the document
self.pdfPageCount = (int)CGPDFDocumentGetNumberOfPages(_pdf);
// load the PDF file into the UIWebVie
UITapGestureRecognizer *singleFingerTap =
[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(handleSingleTap:)];
[self.view addGestureRecognizer:singleFingerTap];
[self.webView loadRequest:_urlRequest];
}
這裏是我如何想要處理單擊在UIVIEW上。我只是想知道是否有任何方法CGPDF當我通過一個頁碼,它滾動到指定頁面
- (void)handleSingleTap:(UITapGestureRecognizer *)recognizer {
}