如何使pdf页面适合vfr阅读器中的屏幕尺寸

时间:2011-10-21 10:20:36

标签: iphone objective-c ipad

您的iPhone应用程序中是否有人使用过vfr阅读器。我正在使用这个vfr阅读器来显示pdf页面。我需要的是当用户将他的方向从纵向更改为横向时我需要使pdf页面适合整个屏幕。我怎样才能做到这一点。

1 个答案:

答案 0 :(得分:5)

只需找到正确的缩放系数并设置内容偏移即可。在ReaderContentView.m中,将以下函数添加到文件顶部

static inline CGFloat ZoomScaleThatFills(CGSize target, CGSize source)
{
    return (target.width / source.width);
}

在同一个文件中,updateMinimumMaximumZoom函数内部更改行如下:

CGFloat zoomScale = ZoomScaleThatFills(targetRect.size, theContentView.bounds.size);

最后,在initWithFrameFunction中,几乎在最后更改行如下:

[self updateMinimumMaximumZoom]; // Update the minimum and maximum zoom scales

self.zoomScale = self.minimumZoomScale; // Set zoom to fit page width

// Set Offset to 0 to scroll to top of page         
self.contentOffset = CGPointMake((0.0f - CONTENT_INSET), (0.0f - CONTENT_INSET)); 

这对我来说,希望它也适合你!

相关问题