Я использую проект ниже GitHubUIPageViewController-PDF Масштабирование не работает xcode?
https://github.com/jackhumphries/UIPageViewController-PDF
проблема PDF загружается и страница локон эффект работает, но я не могу увеличить и уменьшить мой документ в формате PDF, который загружается я пытаюсь отладки а затем почему он не работает, но я не могу найти решение, и я проверил методы делегирования PDFScrollView, все они реализованы, но эти методы не звонят, когда я пытаюсь увеличить/уменьшить масштаб.
вот эти методы:
- (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);
Благодарим вас за то, что вы гениально (Y) благодарит много :) Это работает –
, когда я увеличиваю свой pdf на макс, а затем, когда я пытаюсь уменьшить масштаб актуала, чтобы он не увеличивал масштаб в актуале размер он иногда застревает на уровне увеличения и уменьшает масштаб, а затем не работает должным образом, можете ли вы рассказать мне, что я должен изменить? –
Вы добавили последние две строки, которые я упомянул в 'scrollViewDidEndZooming'? В качестве альтернативы вы можете просто проверить свою вилку структуры: https://github.com/sdesimone/UIPageViewController-PDF – sergio