I have two UIImageView objects inside my view (both 320x480 one above the other). The lower image view is inside a UIScrollView with scrolling and zooming enabled. Now I want to handle touches inside the other image view but it no longer detects any single taps.
我的视图中有两个UIImageView对象(320x480一个在另一个之上)。较低的图像视图位于UIScrollView内,启用了滚动和缩放。现在我想处理其他图像视图中的触摸,但它不再检测任何单击。
I can understand that the UIScrollView handles all the touches which I do on it. But the touches on the image view above the scroll view are also not recognized.
我可以理解UIScrollView处理我在其上做的所有操作。但是滚动视图上方的图像视图上的触摸也无法识别。
Attached is an image with my view hierarchy. Can someone please tell me why the other image view's touches are also handled by the scrollview when it isn't a subview of scroll view?
附件是我的视图层次结构的图像。有人可以告诉我为什么当滚动视图不是滚动视图的子视图时,滚动视图也会处理其他图像视图的触摸?
And if the scrollview is bent on handling touches, how do I recognize touches on the other image view?
如果滚动视图在处理触摸时弯曲,如何识别其他图像视图上的触摸?
Thanks.
alt text http://i44.tinypic.com/14uchs4.png
谢谢。替代文字http://i44.tinypic.com/14uchs4.png
2 个解决方案
#1
By default UIImageViews have userInteractionEnabled=NO;
默认情况下,UIImageViews有userInteractionEnabled = NO;
Try setting it to YES (either in IB or in code).
尝试将其设置为YES(在IB或代码中)。
#2
I'm not sure, it might be that you need to set the frame size and/or content size of the scroll view properly. This page has a diagram of what I'm talking about.
我不确定,可能需要正确设置滚动视图的帧大小和/或内容大小。这个页面有我正在谈论的图表。
#1
By default UIImageViews have userInteractionEnabled=NO;
默认情况下,UIImageViews有userInteractionEnabled = NO;
Try setting it to YES (either in IB or in code).
尝试将其设置为YES(在IB或代码中)。
#2
I'm not sure, it might be that you need to set the frame size and/or content size of the scroll view properly. This page has a diagram of what I'm talking about.
我不确定,可能需要正确设置滚动视图的帧大小和/或内容大小。这个页面有我正在谈论的图表。