如何在 iPhone WWDC 2010 - 104 PhotoScroller 中双击放大

时间:2022-12-28
本文介绍了如何在 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 中双击放大/缩小照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:带有自动布局的 iOS 水平 UIScrollbar 下一篇:使用自动布局时计算 UIScrollView 的 contentSize

相关文章

最新文章