gpt4 book ai didi

iOS pdf在特定坐标处缩放

转载 作者:行者123 更新时间:2023-11-29 03:23:29 24 4
gpt4 key购买 nike

我创建了一个 Ios 应用程序,用于按照 Apple pdf 缩放功能阅读 pdf 文档
https://developer.apple.com/library/ios/samplecode/zoomingpdfviewer/Introduction/Intro.html

但是,我不知道如何在特定坐标处自动缩放 pdf 页面,

我的意思是,当我执行加载方法时,pdf 页面会在特定坐标(x, y)处缩放,例如:(10, 20)

有人帮助我吗?请 !

谢谢!

最佳答案

From Apple's Sample Code of Zooming PDF Viewer

UIScrollView 有 API 可以做到这一点

 [yourScrollView zoomToRect:CGRectMake(X, Y, Width, Height) animated:YES];

基本上,如果您想查看更改时的动画,那么您可以将代码放入 View did Appear 方法中。

#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];


}

关于iOS pdf在特定坐标处缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20778961/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com