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 中双击放大
基础教程推荐
- AdMob 广告未在模拟器中显示 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
