【发布时间】:2014-05-09 07:52:27
【问题描述】:
我的scrollView 是这样的UIViewController --> UIView -->UIScrollView。在滚动视图中,我尝试缩放 PDF 文件。缩放后pdf文件的内容变得模糊。
- (void)handleDoubleTap:(UITapGestureRecognizer *)recognizer
{
for (MagazinePage * page in [self.contentScroll subviews]) {
//maganizepage is a subclass of UIView
//contentScroll is a UIScrollView
[page removeFromSuperview];
}
int i = 0;
zoomScaleValue = zoomScaleValue+500;
self.contentScroll.contentSize = CGSizeMake((self.contentScroll.bounds.size.width+zoomScaleValue) * NO_OF_PAGES_ON_MEMORY,
self.contentScroll.bounds.size.height+zoomScaleValue);
for (MagazinePage * page in collection) {
page.frame = CGRectMake((i) * self.contentScroll.bounds.size.width+(i*zoomScaleValue), 0.0f,
self.contentScroll.bounds.size.width+zoomScaleValue, self.contentScroll.bounds.size.height+zoomScaleValue);
i++;
[self.contentScroll addSubview:page];
}
}
Edit:
-(void)viewDidLoad
{
CFURLRef pdfURL = (__bridge CFURLRef)[NSURL fileURLWithPath:pdfFilePath];
CGPDFDocumentRef pdf = CGPDFDocumentCreateWithURL(pdfURL);
self.contentScroll.delegate = self;
self.contentScroll.contentSize = CGSizeMake(self.contentScroll.bounds.size.width * noofpages, self.contentScroll.bounds.size.height);
CGPDFDocumentRelease(pdf); collection = [NSMutableArray array];
for (int i = 1; i <= noofpages; i++) {
uiviewObject = [[MyUIViewClass alloc] initWithFrame:CGRectMake((i-1) * self.contentScroll.bounds.size.width, 0.0f,self.contentScroll.bounds.size.width, self.contentScroll.bounds.size.height)];
//uiviewObject subclass of UIView
uiviewObject.pdfFileName = pdfName;
uiviewObject.pdfFilePath = pdfPath;
uiviewObject.pageNumber = _scrollPageNumberToLoad;
uiviewObject.navigationDelegate = self;
[collection addObject:uiviewObject];
}
[self loadCollectionToContentScroll: collection];
}
- (void) loadCollectionToContentScroll: (NSMutableArray *) collectionItems {
for (uiviewObject in [self.contentScroll subviews]) {
[uiviewObject removeFromSuperview];
}
int i = 0;
for (uiviewObject in collectionItems) {
uiviewObject.frame = CGRectMake((i) * self.contentScroll.bounds.size.width, 0.0f, self.contentScroll.bounds.size.width, self.contentScroll.bounds.size.height);
i++;
[self.contentScroll addSubview:uiviewObject];
}
}
【问题讨论】:
-
是的,这是正确的行为,当滚动视图被缩放并在其中包含 PDF 时,您将失去质量。您必须重新渲染 PDF,请参阅此 github.com/vfr/Reader 以获取介绍。
-
能否请您详细解释如何重新渲染 pdf.. 我检查了该代码但无法找到。
标签: ios uiview uiscrollview zooming