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

kri*_*han 2 iphone objective-c ipad

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

thu*_*sup 5

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

static inline CGFloat ZoomScaleThatFills(CGSize target, CGSize source)
{
    return (target.width / source.width);
}
Run Code Online (Sandbox Code Playgroud)

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

CGFloat zoomScale = ZoomScaleThatFills(targetRect.size, theContentView.bounds.size);
Run Code Online (Sandbox Code Playgroud)

最后,在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)); 
Run Code Online (Sandbox Code Playgroud)

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