如何在iPhone WWDC 2010 - 104 PhotoScroller中双击放大/缩小照片 [英] How to Zoom In/Out Photo on double Tap in the iPhone WWDC 2010 - 104 PhotoScroller
问题描述
我正在浏览iPhone WWDC 2010 - 104 PhotoScroller App的示例代码。
它与我的项目相关图像(PDF页面图像)工作得很好
I am going through the Sample code of iPhone WWDC 2010 - 104 PhotoScroller App. It's working great with my project related images (PDF Page Images)
但我正在努力检测PhotoScroller应用程序中的触摸。使用多个触摸的缩放由ScrollVoiew处理。现在我想要双击放大/缩小照片。在TilingView类中调用Touchesbegan方法。然后我用[super touchesbegan:withevent:]现在接触到了ImageScrollView类。
but I am struggling detect touches in the PhotoScroller App. The Zooming using multiple touches is handled by the ScrollVoiew. Now I want to Zoom In/out the photo on double Tap. The Touchesbegan method is being called in TilingView Class. Then I used [super touchesbegan: withevent:] and now the touches are in the ImageScrollView Class.
如何在PhotoViewController中获取这些触摸事件。
如何实现放大和缩小触摸?
How to get these touch events in PhotoViewController. How to achieve the zoom in and zoom out on touch ?
任何人都可以在这方面提供帮助?
Can anyone help in this Regard ?
推荐答案
我研究了几个不同的网站,我想出了以下...
I researched several different web sites and I came up with the following...
这段代码放入您的viewDidLoad或viewWillAppear中的方法:
Place this code into your viewDidLoad or viewWillAppear method:
//////////////////////////////
// Listen for Double Tap Zoom
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
[doubleTap setNumberOfTapsRequired:2];
[self.scrollView addGestureRecognizer:doubleTap];
[doubleTap release];
将此添加到您的头文件中:
Add this to your header file:
- (void)handleDoubleTap:(UIGestureRecognizer *)gestureRecognizer;
将此添加到您的实施中:
Add this to your implementation:
- (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];
}
目前这不是以用户双倍的区域为中心点击。
Currently this does not center upon the area where the user double tapped.
这篇关于如何在iPhone WWDC 2010 - 104 PhotoScroller中双击放大/缩小照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!