0
我在我的应用程序中有一个“PDF查看器”。我使用CGPDFDocumentRef
和CGPDFPageRef
来显示PDF。要放大PDF,我使用UIScrollView
。双击放大PDF UIScrollView?
我已经可以捏放大的UIScrollView,但我也想能够双击,以放大。
用一个手指双击可带您到PDF中的不同级别,直到您点击maximumZoomLevel
,然后可以用两根手指双击到minimumZoomLevel
。
我一直无法在互联网上找到解决方案,特别向您显示了这一点,所以我在这里问。我怎么能做到这一点?
在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];
}
是的,这是我试过的。但是我不能在它应该的时候让它工作。更新了问题并添加了一些代码。 – Jacob 2012-04-02 20:20:07
你解决了你的问题吗? – h4cky 2012-04-02 21:07:01