【发布时间】:2012-04-02 20:01:21
【问题描述】:
我的应用程序中有一个“PDF 查看器”。我使用CGPDFDocumentRef 和CGPDFPageRef 来显示PDF。要放大 PDF,我使用 UIScrollView。
我已经能够在 UIScrollView 中进行捏拉缩放,但我也希望能够双击进行缩放。
用一根手指双击可将您带到 PDF 中的不同级别,直到您点击maximumZoomLevel,然后能够用两根手指双击minimumZoomLevel。
我无法在 Internet 上找到特别向您展示这一点的解决方案,所以我在这里询问。我怎么能做到这一点?
在 viewDidLoad 中:
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
[doubleTap setNumberOfTapsRequired:2];
[self.scrollView addGestureRecognizer:doubleTap];
[doubleTap release];
方法:
- (void)handleDoubleTap:(UIGestureRecognizer *)gestureRecognizer
{
if(self.scrollView.zoomScale > self.scrollView.minimumZoomScale)
[self.scrollView setZoomScale:self.scrollView.minimumZoomScale animated:YES];
else
[self.scrollView setZoomScale:self.scrollView.maximumZoomScale animated:YES];
}
【问题讨论】:
标签: objective-c pdf uiscrollview zooming