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