How to Zoom In/Out Photo on double Tap in the iPhone WWDC 2010 - 104 PhotoScroller(如何在 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 中双击放大/缩小照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 iPhone WWDC 2010 - 104 PhotoScroller 中双击放大
基础教程推荐
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01