2

在此处输入图像描述

大家好,

我在检测触摸时遇到了一些问题。请参考黄色和棕色是我的 UIView 的图像,它被子类化以检测透明触摸。我在 UIViews 上添加了三个手势识别器平移、点击和旋转,但是当我将 UIView 子类化并覆盖 - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event 方法以检测添加的所有 Imageviews 时,手势识别器停止在 ImageView 之外工作。如果我不使用子类,那么它无法检测到黄色 UIView 上的 ImageView 触摸。我尝试了此链接的解决方案

将 UIGesture 转发到后面的视图

虽然它与我的要求不一样,但它没有帮助!任何帮助/提示表示赞赏!提前致谢。

4

3 回答 3

1

I have resolved the issue myself. I achieved the my target by applying gesture recognizers on superview not separate for each uiimageview or the colored uiviews. I have added uiviews on superview and now gesture is getting applied to imageview also. And also changed the code in gesture actions so that gesture will get applied to touched imageview and not on superview.

于 2013-08-29T04:39:11.917 回答
0

我发现解决此问题的唯一方法是将您的视图堆栈作为子视图添加到 UIView (A)。它应该与您的透明视图/堆栈上的所有子视图大小相同。您应该在视图控制器中实现手势识别器 if 并将 (A) 连接为 iboutlet(例如,只需将手势识别器拖放到界面构建器中的 A 上)。

(View Controller)
 |->(A)
     |->(1) Need gesture 
     |->(2) Need another gesture
     |->(3) Transparent (messing everything up)

将手势处理程序连接到需要处理它们的 A 的适当子项。

对于视图控制器

@interface AUIViewController : UIViewController <bla, bla, UIGestureRecognizerDelegate >

对于 (1)

- (IBAction)handlePan:(UIPanGestureRecognizer *)recognizer{/*yada yada*/}

在我看来,这是一个苹果错误。

我的回答差不多就是这样,但它是我认为的一个错误的解决方法。

PS,对不起,我没有使用界面生成器来解决这个问题。希望它仍然有帮助

于 2013-08-28T17:51:56.403 回答
0

尝试实现gestureRecognizer应该从你的子类开始,测试识别器的类是否是那些类[gestureRecognizer class] == [UITapGestureRecognizer class],如果是则返回yes。

http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instm/UIView/gestureRecognizerShouldBegin

于 2013-08-02T10:33:40.237 回答