Ios UIPageViewController PDF缩放不工作xcode?
我正在使用下面的github项目 问题是pdf正在加载,页面卷曲效果正在发挥作用,但我无法放大和缩小加载的pdf文档我也尝试过调试,然后为什么它不起作用,但我无法找到解决方案,我检查了PDFScrollView委托方法,它们都已实现,但当我尝试缩放时,这些方法没有调用输入/输出 以下是这些方法:Ios UIPageViewController PDF缩放不工作xcode?,ios,objective-c,uiview,uiscrollview,zooming,Ios,Objective C,Uiview,Uiscrollview,Zooming,我正在使用下面的github项目 问题是pdf正在加载,页面卷曲效果正在发挥作用,但我无法放大和缩小加载的pdf文档我也尝试过调试,然后为什么它不起作用,但我无法找到解决方案,我检查了PDFScrollView委托方法,它们都已实现,但当我尝试缩放时,这些方法没有调用输入/输出 以下是这些方法: - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return self.tiledPDFView
- (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;
}
并将最后两行添加到ScrollViewDiEndZooming
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale
{
....
self.minimumZoomScale = 1.0/scale;
self.maximumZoomScale = 3.0*scale;
}
请注意,更改页面仅在页面处于最低缩放级别时才起作用(如在一些阅读器应用中发生的情况)。非常感谢您,您是一位天才(Y)非常感谢:)当我在max上放大pdf时,它工作正常,然后当我尝试在实际大小上缩小时,它不会在实际大小上缩小它有时会停留在放大级别上,然后缩小,但无法正常工作。你能告诉我应该更改什么吗???你添加了我在
ScrollViewDiEndZooming
中提到的最后两行吗?或者,您可以查看我的框架分支:是的,当然,我在ScrollViewDiEndZooming中添加了最后两行。我还检查了你上面提到的项目,你也可以在那里看到,缩小不能正常工作,放大可以正常工作,但缩小有问题,当我尝试缩小时,它不能完美地响应,它不在其实际位置,缩小有问题,请指导我sergio我哪里做错了谢谢。我拿出了最新版本,但缩小不起作用,当我放大到最大值时,它就不缩小了。